Total Complexity | 10 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Changes | 5 | ||
Bugs | 1 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
8 | final class Config implements ConfigInterface |
||
9 | { |
||
10 | /** |
||
11 | * @return string |
||
12 | */ |
||
13 | public function getClientId(): string |
||
14 | { |
||
15 | $clientId = (string)$this->get('CLIENT_ID'); |
||
16 | if (empty($clientId)) { |
||
17 | throw new RuntimeException( |
||
18 | sprintf(Message::ERROR_GET_ENV_VARIABLE, 'CLIENT_ID') |
||
19 | ); |
||
20 | } |
||
21 | |||
22 | return $clientId; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @return string |
||
27 | */ |
||
28 | public function getClientSecret(): string |
||
29 | { |
||
30 | $clientSecret = (string)$this->get('CLIENT_SECRET'); |
||
31 | if (empty($clientSecret)) { |
||
32 | throw new RuntimeException( |
||
33 | sprintf(Message::ERROR_GET_ENV_VARIABLE, 'CLIENT_SECRET') |
||
34 | ); |
||
35 | } |
||
36 | |||
37 | return $clientSecret; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return string |
||
42 | */ |
||
43 | public function getRedirectUri(): string |
||
44 | { |
||
45 | $redirectUri = (string)$this->get('REDIRECT_URI'); |
||
46 | if (empty($redirectUri)) { |
||
47 | throw new RuntimeException( |
||
48 | sprintf(Message::ERROR_GET_ENV_VARIABLE, 'REDIRECT_URI') |
||
49 | ); |
||
50 | } |
||
51 | |||
52 | return $redirectUri; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | public function getSpotifyUsername(): string |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param string $name |
||
72 | * @return mixed |
||
73 | */ |
||
74 | private function get(string $name) |
||
83 |