Result   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 42
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A getReason() 0 3 1
A getStatus() 0 3 1
1
<?php
2
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
17
declare(strict_types=1);
18
19
namespace Phauthentic\Authorization\Policy;
20
21
/**
22
 * Policy check result
23
 */
24
class Result implements ResultInterface
25
{
26
    /**
27
     * Check status.
28
     *
29
     * @var bool
30
     */
31
    protected $status;
32
/**
33
     * Failure reason.
34
     *
35
     * @var string|null
36
     */
37
    protected $reason;
38
/**
39
     * Constructor
40
     *
41
     * @param bool $status Check status.
42
     * @param string|null $reason Failure reason.
43
     */
44 24
    public function __construct(bool $status, ?string $reason = null)
45
    {
46 24
        $this->status = (bool)$status;
47 24
        if ($reason !== null) {
48 2
            $this->reason = (string)$reason;
49
        }
50 24
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55 2
    public function getReason(): ?string
56
    {
57 2
        return $this->reason;
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63 20
    public function getStatus(): bool
64
    {
65 20
        return $this->status;
66
    }
67
}
68