PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / ClientBuilder.php

ClientBuilder.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.18, at vendor_prefixed/sentry/sentry/src/ClientBuilder.php

113 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sentry;
5
6 use WCPOS\Vendor\Psr\Log\LoggerInterface;
7 use WCPOS\Vendor\Sentry\HttpClient\HttpClient;
8 use WCPOS\Vendor\Sentry\HttpClient\HttpClientInterface;
9 use WCPOS\Vendor\Sentry\Serializer\PayloadSerializer;
10 use WCPOS\Vendor\Sentry\Serializer\RepresentationSerializerInterface;
11 use WCPOS\Vendor\Sentry\Transport\HttpTransport;
12 use WCPOS\Vendor\Sentry\Transport\TransportInterface;
13 /**
14 * A configurable builder for Client objects.
15 */
16 final class ClientBuilder
17 {
18 /**
19 * @var Options The client options
20 */
21 private $options;
22 /**
23 * @var TransportInterface|null The transport
24 */
25 private $transport;
26 /**
27 * @var HttpClientInterface|null The HTTP client
28 */
29 private $httpClient;
30 /**
31 * @var RepresentationSerializerInterface|null The representation serializer to be injected in the client
32 */
33 private $representationSerializer;
34 /**
35 * @var LoggerInterface|null A PSR-3 logger to log internal errors and debug messages
36 */
37 private $logger;
38 /**
39 * @var string The SDK identifier, to be used in {@see Event} and {@see SentryAuth}
40 */
41 private $sdkIdentifier = Client::SDK_IDENTIFIER;
42 /**
43 * @var string The SDK version of the Client
44 */
45 private $sdkVersion = Client::SDK_VERSION;
46 /**
47 * Class constructor.
48 *
49 * @param Options|null $options The client options
50 */
51 public function __construct(?Options $options = null)
52 {
53 $this->options = $options ?? new Options();
54 }
55 /**
56 * @param array<string, mixed> $options The client options, in naked array form
57 */
58 public static function create(array $options = []) : self
59 {
60 return new self(new Options($options));
61 }
62 public function getOptions() : Options
63 {
64 return $this->options;
65 }
66 public function setRepresentationSerializer(RepresentationSerializerInterface $representationSerializer) : self
67 {
68 $this->representationSerializer = $representationSerializer;
69 return $this;
70 }
71 public function getLogger() : ?LoggerInterface
72 {
73 return $this->logger ?? $this->options->getLogger();
74 }
75 public function setLogger(LoggerInterface $logger) : self
76 {
77 $this->logger = $logger;
78 return $this;
79 }
80 public function setSdkIdentifier(string $sdkIdentifier) : self
81 {
82 $this->sdkIdentifier = $sdkIdentifier;
83 return $this;
84 }
85 public function setSdkVersion(string $sdkVersion) : self
86 {
87 $this->sdkVersion = $sdkVersion;
88 return $this;
89 }
90 public function getTransport() : TransportInterface
91 {
92 return $this->transport ?? $this->options->getTransport() ?? new HttpTransport($this->options, $this->getHttpClient(), new PayloadSerializer($this->options), $this->getLogger());
93 }
94 public function setTransport(TransportInterface $transport) : self
95 {
96 $this->transport = $transport;
97 return $this;
98 }
99 public function getHttpClient() : HttpClientInterface
100 {
101 return $this->httpClient ?? $this->options->getHttpClient() ?? new HttpClient($this->sdkIdentifier, $this->sdkVersion);
102 }
103 public function setHttpClient(HttpClientInterface $httpClient) : self
104 {
105 $this->httpClient = $httpClient;
106 return $this;
107 }
108 public function getClient() : ClientInterface
109 {
110 return new Client($this->options, $this->getTransport(), $this->sdkIdentifier, $this->sdkVersion, $this->representationSerializer, $this->getLogger());
111 }
112 }
113