TimeBefore::getValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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