Passed
Push — master ( c0f32c...e879f4 )
by Chema
04:17 queued 41s
created

StockTickerConfig   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 20%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 13
c 1
b 0
f 0
dl 0
loc 50
ccs 4
cts 20
cp 0.2
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getSlackBotUserOauthAccessToken() 0 3 1
A isTrue() 0 3 1
A getTemplatesDir() 0 3 1
A getMailerPassword() 0 3 1
A getMailerUsername() 0 3 1
A isDebug() 0 3 1
A getSlackDestinyChannelId() 0 3 1
A __construct() 0 4 1
A getToAddress() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTicker;
6
7
final class StockTickerConfig implements StockTickerConfigInterface
8
{
9
    private string $templatesDir;
10
11
    private array $env;
12
13 4
    public function __construct(string $templatesDir = '', array $env = [])
14
    {
15 4
        $this->templatesDir = $templatesDir;
16 4
        $this->env = $env;
17 4
    }
18
19
    public function getTemplatesDir(): string
20
    {
21
        return $this->templatesDir;
22
    }
23
24
    public function getToAddress(): string
25
    {
26
        return $this->env['TO_ADDRESS'];
27
    }
28
29
    public function getMailerUsername(): string
30
    {
31
        return $this->env['MAILER_USERNAME'];
32
    }
33
34
    public function getMailerPassword(): string
35
    {
36
        return $this->env['MAILER_PASSWORD'];
37
    }
38
39
    public function getSlackDestinyChannelId(): string
40
    {
41
        return $this->env['SLACK_DESTINY_CHANNEL_ID'];
42
    }
43
44
    public function getSlackBotUserOauthAccessToken(): string
45
    {
46
        return $this->env['SLACK_BOT_USER_OAUTH_ACCESS_TOKEN'];
47
    }
48
49
    public function isDebug(): bool
50
    {
51
        return $this->isTrue($this->env['DEBUG'] ?? null);
52
    }
53
54
    private function isTrue(?string $bool): bool
55
    {
56
        return in_array($bool, [true, 'true', '1', 'yes'], true);
57
    }
58
}
59