Passed
Push — master ( f6cdcb...e2cbe1 )
by Chema
03:23
created

StockTickerConfig::getMailerUsername()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 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 13
    public function __construct(string $templatesDir = '', array $env = [])
14
    {
15 13
        $this->templatesDir = $templatesDir;
16 13
        $this->env = $env;
17 13
    }
18
19 1
    public function getTemplatesDir(): string
20
    {
21 1
        return $this->templatesDir;
22
    }
23
24 1
    public function getToAddress(): string
25
    {
26 1
        return $this->env['TO_ADDRESS'];
27
    }
28
29 1
    public function getMailerUsername(): string
30
    {
31 1
        return $this->env['MAILER_USERNAME'];
32
    }
33
34 1
    public function getMailerPassword(): string
35
    {
36 1
        return $this->env['MAILER_PASSWORD'];
37
    }
38
39 1
    public function getSlackDestinyChannelId(): string
40
    {
41 1
        return $this->env['SLACK_DESTINY_CHANNEL_ID'];
42
    }
43
44 1
    public function getSlackBotUserOauthAccessToken(): string
45
    {
46 1
        return $this->env['SLACK_BOT_USER_OAUTH_ACCESS_TOKEN'];
47
    }
48
49 6
    public function isDebug(): bool
50
    {
51 6
        return $this->isTrue($this->env['DEBUG'] ?? null);
52
    }
53
54 6
    private function isTrue(?string $bool): bool
55
    {
56 6
        return in_array($bool, ['true', '1', 'yes'], true);
57
    }
58
}
59