1: | <?php |
2: | namespace Worldline\Connect\Sdk\Communication; |
3: | |
4: | use stdClass; |
5: | use Worldline\Connect\Sdk\CommunicatorConfiguration; |
6: | use Worldline\Connect\Sdk\Domain\ShoppingCartExtension; |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | class MetadataProvider |
14: | { |
15: | const SDK_VERSION = '7.2.0'; |
16: | |
17: | |
18: | private $integrator; |
19: | |
20: | |
21: | private $shoppingCartExtension; |
22: | |
23: | |
24: | |
25: | |
26: | public function __construct(CommunicatorConfiguration $communicatorConfiguration) { |
27: | $this->integrator = $communicatorConfiguration->getIntegrator(); |
28: | $this->shoppingCartExtension = $communicatorConfiguration->getShoppingCartExtension(); |
29: | } |
30: | |
31: | |
32: | |
33: | |
34: | public function getServerMetaInfoValue() |
35: | { |
36: | |
37: | $serverMetaInfo = new stdClass(); |
38: | $serverMetaInfo->platformIdentifier = sprintf('%s; php version %s', php_uname(), phpversion()); |
39: | $serverMetaInfo->sdkIdentifier = 'PHPServerSDK/v' . static::SDK_VERSION; |
40: | $serverMetaInfo->sdkCreator = 'Worldline'; |
41: | $serverMetaInfo->integrator = $this->integrator; |
42: | if (!is_null($this->shoppingCartExtension)) { |
43: | $serverMetaInfo->shoppingCartExtension = $this->shoppingCartExtension->toObject(); |
44: | } |
45: | |
46: | return base64_encode(json_encode($serverMetaInfo, JSON_UNESCAPED_SLASHES)); |
47: | } |
48: | } |
49: | |