Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
AbstractAuth | |
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
1 / 1 |
setAccountName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getAccountName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasAccountName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAccountKey | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getAccountKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasAccountKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getBaseUri | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAuthorizationHeader | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
signRequest | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Storage\Adapter\Azure; |
15 | |
16 | use Pop\Http\Client\Request; |
17 | |
18 | /** |
19 | * Azure storage abstract auth class |
20 | * |
21 | * @category Pop |
22 | * @package Pop\Storage |
23 | * @author Nick Sagona, III <dev@nolainteractive.com> |
24 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
25 | * @license http://www.popphp.org/license New BSD License |
26 | * @version 2.0.0 |
27 | */ |
28 | abstract class AbstractAuth implements AuthInterface |
29 | { |
30 | |
31 | /** |
32 | * Account name |
33 | * @var ?string |
34 | */ |
35 | protected ?string $accountName = null; |
36 | |
37 | /** |
38 | * Account key |
39 | * @var ?string |
40 | */ |
41 | protected ?string $accountKey = null; |
42 | |
43 | /** |
44 | * Set account name |
45 | * |
46 | * @param string $accountName |
47 | * @return AbstractAuth |
48 | */ |
49 | public function setAccountName(string $accountName): AbstractAuth |
50 | { |
51 | $this->accountName = $accountName; |
52 | return $this; |
53 | } |
54 | |
55 | /** |
56 | * Get account name |
57 | * |
58 | * @return ?string |
59 | */ |
60 | public function getAccountName(): ?string |
61 | { |
62 | return $this->accountName; |
63 | } |
64 | |
65 | /** |
66 | * Has account name |
67 | * |
68 | * @return bool |
69 | */ |
70 | public function hasAccountName(): bool |
71 | { |
72 | return ($this->accountName !== null); |
73 | } |
74 | |
75 | /** |
76 | * Set account key |
77 | * |
78 | * @param string $accountKey |
79 | * @return AbstractAuth |
80 | */ |
81 | public function setAccountKey(string $accountKey): AbstractAuth |
82 | { |
83 | $this->accountKey = $accountKey; |
84 | return $this; |
85 | } |
86 | |
87 | /** |
88 | * Get account key |
89 | * |
90 | * @return ?string |
91 | */ |
92 | public function getAccountKey(): ?string |
93 | { |
94 | return $this->accountKey; |
95 | } |
96 | |
97 | /** |
98 | * Has account key |
99 | * |
100 | * @return bool |
101 | */ |
102 | public function hasAccountKey(): bool |
103 | { |
104 | return ($this->accountKey !== null); |
105 | } |
106 | |
107 | /** |
108 | * Get account key |
109 | * |
110 | * @return string |
111 | */ |
112 | public function getBaseUri(): string |
113 | { |
114 | return 'https://' . $this->accountName . '.blob.core.windows.net'; |
115 | } |
116 | |
117 | /** |
118 | * Returns authorization header to be included in the request. |
119 | * |
120 | * @param array $headers |
121 | * @param string $url |
122 | * @param array $queryParams |
123 | * @param string $httpMethod |
124 | * @return string |
125 | */ |
126 | abstract public function getAuthorizationHeader(array $headers, string $url, array $queryParams, string $httpMethod): string; |
127 | |
128 | /** |
129 | * Adds authentication header to the request headers. |
130 | * |
131 | * @param Request $request |
132 | * @return Request |
133 | */ |
134 | abstract public function signRequest(Request $request): Request; |
135 | |
136 | } |