TimeBefore   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 20
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A childCanBeSatisfied() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RemotelyLiving\Doorkeeper\Rules;
6
7
use RemotelyLiving\Doorkeeper\RequestorInterface;
8
use RemotelyLiving\Doorkeeper\Utilities;
9
10
final class TimeBefore extends AbstractRule
11
{
12
    private \DateTimeImmutable $timeBefore;
13
14
    private Utilities\Time $timeUtility;
15
16
    public function __construct(string $timeBefore, Utilities\Time $timeUtility = null)
17
    {
18
        $this->timeUtility = $timeUtility ?? new Utilities\Time();
19
        $this->timeBefore = $this->timeUtility->getImmutableDateTime($timeBefore);
20
    }
21
22
    public function getValue()
23
    {
24
        return $this->timeBefore->format('Y-m-d H:i:s');
25
    }
26
27
    protected function childCanBeSatisfied(RequestorInterface $requestor = null): bool
28
    {
29
        return $this->timeBefore > $this->timeUtility->getImmutableDateTime('now');
30
    }
31
}
32