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

ForbiddenException::setResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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