ControllerEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 51
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getArguments() 0 3 1
A getController() 0 3 1
A setController() 0 3 1
A setArguments() 0 3 1
A __construct() 0 6 1
A setArgument() 0 3 1
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of Biurad opensource projects.
5
 *
6
 * @copyright 2019 Biurad Group (https://biurad.com/)
7
 * @license   https://opensource.org/licenses/BSD-3-Clause License
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Flange\Event;
14
15
use Flange\Application;
16
use Psr\Http\Message\ServerRequestInterface as Request;
17
18
/**
19
 * Allows filtering of controller arguments.
20
 *
21
 * You can call getController() to retrieve the controller and getArguments
22
 * to retrieve the current arguments. With setArguments() you can replace
23
 * arguments that are used to call the controller.
24
 *
25
 * Arguments set in the event must be compatible with the signature of the controller.
26
 *
27
 * @author Divine Niiquaye Ibok <[email protected]>
28
 */
29
final class ControllerEvent extends KernelEvent
30
{
31
    /** @var array<int|string,mixed> */
32
    private array $arguments;
33
34
    /** @var mixed */
35
    private $controller;
36
37
    /**
38
     * @param mixed $controller
39
     */
40
    public function __construct(Application $app, Request $request, $controller, array $arguments)
41
    {
42
        parent::__construct($app, $request);
43
44
        $this->controller = $controller;
45
        $this->arguments = $arguments;
46
    }
47
48
    /**
49
     * @return mixed
50
     */
51
    public function getController()
52
    {
53
        return $this->controller;
54
    }
55
56
    /**
57
     * @param mixed $controller
58
     */
59
    public function setController($controller): void
60
    {
61
        $this->controller = $controller;
62
    }
63
64
    public function getArguments(): array
65
    {
66
        return $this->arguments;
67
    }
68
69
    public function setArguments(array $arguments): void
70
    {
71
        $this->arguments = $arguments;
72
    }
73
74
    /**
75
     * @param mixed $value
76
     */
77
    public function setArgument(string $name, $value): void
78
    {
79
        $this->arguments[$name] = $value;
80
    }
81
}
82