TokenQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 14
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A notExpired() 0 5 1
A whereRecipient() 0 3 1
1
<?php
2
3
namespace Wearesho\Yii\Queries;
4
5
use Carbon\Carbon;
6
use Carbon\CarbonInterval;
7
8
use Wearesho\Yii\Interfaces\TokenQueryInterface;
9
use Wearesho\Yii\Models\Token;
10
11
use yii\db\ActiveQuery;
12
13
/**
14
 * @see Token
15
 */
16
class TokenQuery extends ActiveQuery implements TokenQueryInterface
17
{
18
19
    public function notExpired(CarbonInterval $expirePeriod): TokenQueryInterface
20
    {
21
        return $this->andWhere(['>=',
22
            'created_at',
23
            Carbon::now()->sub($expirePeriod)->toDateTimeString()
24
        ]);
25
    }
26
27
    public function whereRecipient(string $recipient): TokenQueryInterface
28 16
    {
29
        return $this->andWhere(['=', 'recipient', $recipient]);
30 16
    }
31
}
32