Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
VultrConfig | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
generateHeaders | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
getBaseURI | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Vultr\VultrPhp; |
6 | |
7 | class VultrConfig |
8 | { |
9 | public const VERSION = '1.0.2'; |
10 | public const API_VERSION = 'v2'; |
11 | public const API_URI = 'https://api.vultr.com/'; |
12 | public const USERAGENT = 'VultrPhp/'.self::VERSION. '(API_VERSION: '.self::API_VERSION.')'; |
13 | |
14 | public const MANDATORY_HEADERS = [ |
15 | 'Content-Type' => 'application/json', |
16 | 'Accept' => 'application/json', |
17 | 'User-Agent' => self::USERAGENT, |
18 | VultrAuth::AUTHORIZATION_HEADER => '', |
19 | ]; |
20 | |
21 | public static function generateHeaders(VultrAuth $auth) : array |
22 | { |
23 | $headers = []; |
24 | foreach (self::MANDATORY_HEADERS as $option => $value) |
25 | { |
26 | $headers[$option] = $value; |
27 | } |
28 | $headers[VultrAuth::AUTHORIZATION_HEADER] = $auth->getBearerTokenHead(); |
29 | |
30 | return $headers; |
31 | } |
32 | |
33 | public static function getBaseURI() : string |
34 | { |
35 | return self::API_URI.self::API_VERSION.'/'; |
36 | } |
37 | } |
38 |