Test Failed
Pull Request — master (#1)
by Florian
05:12 queued 03:23
created

Result::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 2
nc 2
nop 2
1
<?php
2
declare(strict_types=1);
3
/**
4
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
5
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
6
 *
7
 * Licensed under The MIT License
8
 * For full copyright and license information, please see the LICENSE.txt
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
12
 * @link          https://cakephp.org CakePHP(tm) Project
13
 * @since         1.1.0
14
 * @license       https://opensource.org/licenses/mit-license.php MIT License
15
 */
16
namespace Phauthentic\Authorization\Policy;
17
18
/**
19
 * Policy check result
20
 */
21
class Result implements ResultInterface
22
{
23
    /**
24
     * Check status.
25
     *
26
     * @var bool
27
     */
28
    protected $status;
29
30
    /**
31
     * Failure reason.
32
     *
33
     * @var string|null
34
     */
35
    protected $reason;
36
37
    /**
38
     * Constructor
39
     *
40
     * @param bool $status Check status.
41
     * @param string|null $reason Failure reason.
42
     */
43
    public function __construct(bool $status, ?string $reason = null)
44
    {
45
        $this->status = (bool)$status;
46
        if ($reason !== null) {
47
            $this->reason = (string)$reason;
48
        }
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public function getReason(): ?string
55
    {
56
        return $this->reason;
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62
    public function getStatus(): bool
63
    {
64
        return $this->status;
65
    }
66
}
67