Test Failed
Push — master ( f1767b...06a3a6 )
by Divine Niiquaye
03:30
created

ControllerEvent::getReflection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of DivineNii opensource projects.
7
 *
8
 * PHP version 7.4 and above required
9
 *
10
 * @author    Divine Niiquaye Ibok <[email protected]>
11
 * @copyright 2019 DivineNii (https://divinenii.com/)
12
 * @license   https://opensource.org/licenses/BSD-3-Clause License
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 */
17
18
namespace Rade\Event;
19
20
use Psr\Http\Message\ServerRequestInterface as Request;
21
use Rade\Application;
22
23
/**
24
 * Allows filtering of controller arguments.
25
 *
26
 * You can call getController() to retrieve the controller and getArguments
27
 * to retrieve the current arguments. With setArguments() you can replace
28
 * arguments that are used to call the controller.
29
 *
30
 * Arguments set in the event must be compatible with the signature of the controller.
31
 *
32
 * @author Divine Niiquaye Ibok <[email protected]>
33
 */
34
final class ControllerEvent extends KernelEvent
35
{
36
    private \ReflectionFunctionAbstract $ref;
37
    private array $arguments;
38
39
    /** @var mixed */
40 4
    private $controller;
41
42 4
    /**
43
     * @param mixed $controller
44 4
     */
45 4
    public function __construct(Application $app, $controller, \ReflectionFunctionAbstract $ref, array $arguments, Request $request)
46
    {
47
        parent::__construct($app, $request);
48
49
        $this->controller = $controller;
50
        $this->arguments = $arguments;
51 4
        $this->ref = $ref;
52
    }
53 4
54
    public function getReflection(): \ReflectionFunctionAbstract
55
    {
56
        return $this->ref;
57
    }
58
59
    /**
60
     * @return mixed
61
     */
62
    public function getController()
63
    {
64 4
        return $this->controller;
65
    }
66 4
67
    /**
68
     * @param mixed $controller
69
     */
70
    public function setController($controller): void
71
    {
72
        $this->controller = $controller;
73
    }
74
75
    public function getArguments(): array
76
    {
77
        return $this->arguments;
78
    }
79
80
    public function setArguments(array $arguments): void
81
    {
82
        $this->arguments = $arguments;
83
    }
84
85
    /**
86
     * @param mixed $value
87
     */
88
    public function setArgument(string $name, $value): void
89
    {
90
        $this->arguments[$name] = $value;
91
    }
92
}
93