1: <?php
2: /**
3: * Copyright 2012-2014 Rackspace US, Inc.
4: *
5: * Licensed under the Apache License, Version 2.0 (the "License");
6: * you may not use this file except in compliance with the License.
7: * You may obtain a copy of the License at
8: *
9: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: namespace OpenCloud\Common\Http;
19:
20: use Guzzle\Http\Client as GuzzleClient;
21: use Guzzle\Http\Curl\CurlVersion;
22: use OpenCloud\Common\Exceptions\UnsupportedVersionError;
23:
24: /**
25: * Base client object which handles HTTP transactions. Each service is based off of a Client which acts as a
26: * centralized parent.
27: */
28: class Client extends GuzzleClient
29: {
30: const VERSION = '1.9.0';
31: const MINIMUM_PHP_VERSION = '5.3.0';
32:
33: public function __construct($baseUrl = '', $config = null)
34: {
35: // @codeCoverageIgnoreStart
36: if (PHP_VERSION < self::MINIMUM_PHP_VERSION) {
37: throw new UnsupportedVersionError(sprintf(
38: 'You must have PHP version >= %s installed.',
39: self::MINIMUM_PHP_VERSION
40: ));
41: }
42: // @codeCoverageIgnoreEnd
43:
44: parent::__construct($baseUrl, $config);
45: }
46:
47: public function getDefaultUserAgent()
48: {
49: return 'OpenCloud/' . self::VERSION
50: . ' cURL/' . CurlVersion::getInstance()->get('version')
51: . ' PHP/' . PHP_VERSION;
52: }
53:
54: public function getUserAgent()
55: {
56: return $this->userAgent;
57: }
58: }
59: