1 <?php
2
3 namespace PayPal\Common;
4
5 6 7 8 9 10
11 class PayPalUserAgent
12 {
13
14 15 16 17 18 19 20 21
22 public static function getValue($sdkName, $sdkVersion)
23 {
24 $featureList = array(
25 'platform-ver=' . PHP_VERSION,
26 'bit=' . self::_getPHPBit(),
27 'os=' . str_replace(' ', '_', php_uname('s') . ' ' . php_uname('r')),
28 'machine=' . php_uname('m')
29 );
30 if (defined('OPENSSL_VERSION_TEXT')) {
31 $opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
32 $featureList[] = 'crypto-lib-ver=' . $opensslVersion[1];
33 }
34 if (function_exists('curl_version')) {
35 $curlVersion = curl_version();
36 $featureList[] = 'curl=' . $curlVersion['version'];
37 }
38 return sprintf("PayPalSDK/%s %s (%s)", $sdkName, $sdkVersion, implode('; ', $featureList));
39 }
40
41 42 43 44 45
46 private static function _getPHPBit()
47 {
48 switch (PHP_INT_SIZE) {
49 case 4:
50 return '32';
51 case 8:
52 return '64';
53 default:
54 return PHP_INT_SIZE;
55 }
56 }
57 }
58