ExpiredAuthorizer.php 697 Bytes
Newer Older
1
2
3
4
5
6
<?php


namespace Source\UseCases\Door\Access\Authorizers;

use Carbon\Carbon;
7
use Source\Entities\Door;
8
9
10
11
12
13
14
15
use Source\Entities\User;
use Source\UseCases\Door\Access\AccessAuthorizer;

class ExpiredAuthorizer implements AccessAuthorizer
{
    /**
     * @inheritDoc
     */
16
    public function check(?User $user, Carbon $date, Door $door, string $doorcode, ?string $commandString): int
17
18
19
20
21
22
23
    {
        if ($user && !$user->isActiveForDate($date)) {
            return self::DENY;
        }

        return self::CONTINUE;
    }
Jacob Priddy's avatar
Jacob Priddy committed
24
25
26
27
28
29
30
31
32

    /**
     * @inheritDoc
     */
    public function getReason(): string
    {
        // We only deny, can only be one reason
        return 'User has expired.';
    }
33
}