| Total Complexity | 5 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class UserAgent |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | private static $userAgent = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @return string |
||
| 23 | */ |
||
| 24 | public function __toString() |
||
| 25 | { |
||
| 26 | $this->append('AlibabaCloud', null); |
||
| 27 | $os = \PHP_OS; |
||
| 28 | $os_version = php_uname('r'); |
||
| 29 | $os_mode = php_uname('m'); |
||
| 30 | $this->append("($os $os_version; $os_mode)", null); |
||
| 31 | $this->append('PHP', \PHP_VERSION); |
||
| 32 | $this->append('Client', AlibabaCloud::VERSION); |
||
| 33 | $this->append('Zend', zend_version()); |
||
| 34 | $this->append('Guzzle', Client::VERSION); |
||
| 35 | $this->append( |
||
| 36 | 'CURL', |
||
| 37 | isset(\curl_version()['version']) |
||
| 38 | ? \curl_version()['version'] |
||
| 39 | : '' |
||
| 40 | ); |
||
| 41 | |||
| 42 | $newUserAgent = []; |
||
| 43 | foreach (self::$userAgent as $key => $value) { |
||
| 44 | if ($value === null) { |
||
| 45 | $newUserAgent[] = $key; |
||
| 46 | continue; |
||
| 47 | } |
||
| 48 | $newUserAgent[] = $key . '/' . $value; |
||
| 49 | } |
||
| 50 | return \implode(' ', $newUserAgent); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * set User Agent of Alibaba Cloud. |
||
| 55 | * |
||
| 56 | * @param string $name |
||
| 57 | * @param string $value |
||
| 58 | * |
||
| 59 | * @return $this |
||
| 60 | */ |
||
| 61 | public function append($name, $value) |
||
| 66 | } |
||
| 67 | } |
||
| 68 |