33namespace SumUp \Utils ;
44
55use SumUp \Authentication \AccessToken ;
6+ use SumUp \SdkInfo ;
67
78/**
89 * Class Headers
1112 */
1213class Headers
1314{
14- /**
15- * Cached value of the project's version.
16- *
17- * @var string $cacheVersion
18- */
19- protected static $ cacheVersion ;
2015 /**
2116 * Get the common header for Content-Type: application/json.
2217 *
@@ -49,39 +44,6 @@ public static function getAuth(AccessToken $accessToken)
4944 return ['Authorization ' => 'Bearer ' . $ accessToken ->getValue ()];
5045 }
5146
52- /**
53- * Get custom array.
54- *
55- * @return array
56- */
57- public static function getTrk ()
58- {
59- return ['X-SDK ' => 'PHP-SDK/v ' . self ::getProjectVersion () . ' PHP/v ' . phpversion ()];
60- }
61-
62- /**
63- * Get the version of the project accroding to the composer.json
64- *
65- * @return string
66- */
67- public static function getProjectVersion ()
68- {
69- if (is_null (self ::$ cacheVersion )) {
70- self ::$ cacheVersion = 'unknown ' ;
71- $ pathToComposer = dirname (__FILE__ ) . '/../../../composer.json ' ;
72-
73- if (is_readable ($ pathToComposer )) {
74- $ content = file_get_contents ($ pathToComposer );
75- $ content = json_decode ($ content , true );
76- if (is_array ($ content ) && !empty ($ content ['version ' ])) {
77- self ::$ cacheVersion = $ content ['version ' ];
78- }
79- }
80- }
81-
82- return self ::$ cacheVersion ;
83- }
84-
8547 /**
8648 * Get standard headers needed for every request.
8749 *
@@ -90,7 +52,7 @@ public static function getProjectVersion()
9052 public static function getStandardHeaders ()
9153 {
9254 $ headers = self ::getCTJson ();
93- $ headers += self :: getTrk ();
55+ $ headers[ ' User-Agent ' ] = SdkInfo:: getUserAgent ();
9456 return $ headers ;
9557 }
9658}
0 commit comments