ForbiddenException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 39
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setResult() 0 4 1
A getResult() 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.0.0
14
 * @license       https://opensource.org/licenses/mit-license.php MIT License
15
 */
16
17
declare(strict_types=1);
18
19
namespace Phauthentic\Authorization\Exception;
20
21
use Phauthentic\Authorization\Policy\ResultInterface;
22
23
/**
24
 * Forbidden Exception
25
 */
26
class ForbiddenException extends Exception
27
{
28
    /**
29
     * {@inheritDoc}
30
     */
31
    protected $code = 403;
32
33
    /**
34
     * {@inheritDoc}
35
     */
36
    protected $messageTemplate = 'Identity is not authorized to perform `%s` on `%s`.';
37
38
    /**
39
     * Policy check result.
40
     *
41
     * @var \Phauthentic\Authorization\Policy\ResultInterface|null
42
     */
43
    protected $result;
44
45
    /**
46
     * Returns policy check result if passed to the exception.
47
     *
48
     * @param \Phauthentic\Authorization\Policy\ResultInterface|null $result Result
49
     * @return $this
50
     */
51
    public function setResult(?ResultInterface $result)
52
    {
53
        $this->result = $result;
54
        return $this;
55
    }
56
57
    /**
58
     * Returns policy check result if passed to the exception.
59
     *
60
     * @return \Phauthentic\Authorization\Policy\ResultInterface|null
61
     */
62
    public function getResult(): ?ResultInterface
63
    {
64
        return $this->result;
65
    }
66
}
67