Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

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