1: <?php
2:
3: namespace Guzzle\Http\Curl;
4:
5: /**
6: * Class used for querying curl_version data
7: */
8: class CurlVersion
9: {
10: /**
11: * @var array curl_version() information
12: */
13: protected $version;
14:
15: /**
16: * @var CurlVersion
17: */
18: protected static $instance;
19:
20: /**
21: * @var string Default user agent
22: */
23: protected $userAgent;
24:
25: /**
26: * Get the singleton instance of the CurlVersion object
27: *
28: * @return CurlVersion
29: */
30: public static function getInstance()
31: {
32: if (!self::$instance) {
33: self::$instance = new self();
34: }
35:
36: return self::$instance;
37: }
38:
39: /**
40: * Get all of the curl_version() data
41: *
42: * @return array
43: */
44: public function getAll()
45: {
46: if (!$this->version) {
47: $this->version = curl_version();
48: }
49:
50: return $this->version;
51: }
52:
53: /**
54: * Get a specific type of curl information
55: *
56: * @param string $type Version information to retrieve. This value is one of:
57: * - version_number: cURL 24 bit version number
58: * - version: cURL version number, as a string
59: * - ssl_version_number: OpenSSL 24 bit version number
60: * - ssl_version: OpenSSL version number, as a string
61: * - libz_version: zlib version number, as a string
62: * - host: Information about the host where cURL was built
63: * - features: A bitmask of the CURL_VERSION_XXX constants
64: * - protocols: An array of protocols names supported by cURL
65: *
66: * @return string|float|bool if the $type is found, and false if not found
67: */
68: public function get($type)
69: {
70: $version = $this->getAll();
71:
72: return isset($version[$type]) ? $version[$type] : false;
73: }
74: }
75: