1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace TK\API; |
||
4 | |||
5 | final class Environment |
||
6 | { |
||
7 | private $apiUrl; |
||
8 | private $apiKey; |
||
9 | private $apiSecret; |
||
10 | private $clientUsername; |
||
11 | private $channel; |
||
12 | private $appName; |
||
13 | |||
14 | public function __construct( |
||
15 | string $apiUrl, |
||
16 | string $apiKey, |
||
17 | string $apiSecret, |
||
18 | ?string $clientUsername = null, |
||
19 | ?string $appName = null, |
||
20 | ?string $channel = 'WEB' |
||
21 | ) { |
||
22 | $this->apiUrl = $apiUrl; |
||
23 | $this->apiKey = $apiKey; |
||
24 | $this->apiSecret = $apiSecret; |
||
25 | $this->clientUsername = $clientUsername; |
||
26 | $this->channel = $channel; |
||
27 | $this->appName = $appName; |
||
28 | } |
||
29 | |||
30 | public static function createWithUserName ( |
||
31 | string $apiUrl, |
||
32 | string $apiKey, |
||
33 | string $apiSecret, |
||
34 | ?string $clientUsername = null, |
||
35 | ?string $channel = null |
||
36 | ) :self { |
||
37 | return new self($apiUrl, $apiKey, $apiSecret, $clientUsername, null, $channel); |
||
38 | } |
||
39 | public static function createWithAppName ( |
||
40 | string $apiUrl, |
||
41 | string $apiKey, |
||
42 | string $apiSecret, |
||
43 | ?string $appName = null, |
||
44 | ?string $channel = null |
||
45 | ) :self { |
||
46 | return new self($apiUrl, $apiKey, $apiSecret, null, $appName, $channel); |
||
47 | } |
||
48 | public function getApiUrl() :string |
||
49 | { |
||
50 | return $this->apiUrl; |
||
51 | } |
||
52 | |||
53 | public function getApiKey() :string |
||
54 | { |
||
55 | return $this->apiKey; |
||
56 | } |
||
57 | |||
58 | public function getApiSecret() : string |
||
59 | { |
||
60 | return $this->apiSecret; |
||
61 | } |
||
62 | |||
63 | public function getClientUsername() : string |
||
64 | { |
||
65 | return $this->clientUsername; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
66 | } |
||
67 | |||
68 | public function getChannel() : string |
||
69 | { |
||
70 | return $this->channel ?? 'WEB'; |
||
71 | } |
||
72 | public function getAppName() : string |
||
73 | { |
||
74 | return $this->appName; |
||
0 ignored issues
–
show
|
|||
75 | } |
||
76 | } |
||
77 |