Test Failed
Push — master ( c65274...a98fd4 )
by Alexander
18:33
created

TokenRepositoryConfig::getDeliveryLimit()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Wearesho\Yii\Configs;
6
7
use Carbon\CarbonInterval;
8
9
use Wearesho\Yii\Interfaces\TokenRepositoryConfigInterface;
10
11
use yii\base\BaseObject;
12
use yii\base\Configurable;
13
14
class TokenRepositoryConfig extends BaseObject implements TokenRepositoryConfigInterface, Configurable
15
{
16
    public string $expirePeriodKey = 'TOKEN_EXPIRE_MINUTES';
17
    public string $verifyLimitKey = 'TOKEN_VERIFY_LIMIT';
18
    public string $deliveryLimitKey = 'TOKEN_DELIVERY_LIMIT';
19
20
    public int $defaultExpirePeriod = 30;
21
    public int $defaultVerifyLimit = 3;
22
    public int $defaultDeliveryLimit = 3;
23
24
    public function getExpirePeriod(): CarbonInterval
25
    {
26
        $minutes = (int)getenv($this->expirePeriodKey) ?: $this->defaultExpirePeriod;
27
        return CarbonInterval::minutes((int) $minutes);
28
    }
29
30 1
    public function getVerifyLimit(): int
31
    {
32 1
        return (int)getenv($this->verifyLimitKey) ?: $this->defaultVerifyLimit;
33 1
    }
34
35
    public function getDeliveryLimit(): int
36
    {
37
        return (int)getenv($this->deliveryLimitKey) ?: $this->defaultDeliveryLimit;
38
    }
39
}
40