Passed
Pull Request — master (#3)
by Rafal
04:51 queued 02:40
created

Config::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php declare(strict_types=1);
2
3
namespace SpotifyApiConnect\Domain\Model;
4
5
use SpotifyApiConnect\Message;
6
use RuntimeException;
7
8
final class Config implements ConfigInterface
9
{
10
    /**
11
     * @return string
12
     */
13
    public function getClientId(): string
14
    {
15
        $clientId = (string)getenv('CLIENT_ID');
16
        if (empty($clientId)) {
17
            throw new RuntimeException(
18
                sprintf(Message::ERROR_GET_ENV_VARIABLE, CLIENT_ID)
0 ignored issues
show
Bug introduced by
The constant SpotifyApiConnect\Domain\Model\CLIENT_ID was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
19
            );
20
        }
21
22
        return $clientId;
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    public function getClientSecret(): string
29
    {
30
        $clientSecret = (string)getenv('CLIENT_SECRET');
31
        if (empty($clientSecret)) {
32
            throw new RuntimeException(
33
                sprintf(Message::ERROR_GET_ENV_VARIABLE, CLIENT_SECRET)
0 ignored issues
show
Bug introduced by
The constant SpotifyApiConnect\Domain\Model\CLIENT_SECRET was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
            );
35
        }
36
37
        return $clientSecret;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getRedirectUri(): string
44
    {
45
        $redirectUri = (string)getenv('REDIRECT_URI');
46
        if (empty($redirectUri)) {
47
            throw new RuntimeException(
48
                sprintf(Message::ERROR_GET_ENV_VARIABLE, REDIRECT_URI)
0 ignored issues
show
Bug introduced by
The constant SpotifyApiConnect\Domain\Model\REDIRECT_URI was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
49
            );
50
        }
51
52
        return $redirectUri;
53
    }
54
55
56
}