1 | <?php |
||
2 | |||
3 | namespace Nip\Dispatcher\Commands; |
||
4 | |||
5 | use Nip\Dispatcher\Exceptions\ForwardException; |
||
6 | use Psr\Http\Message\ServerRequestInterface; |
||
7 | |||
8 | /** |
||
9 | * Class CommandFactory |
||
10 | * @package Nip\Dispatcher\Commands |
||
11 | */ |
||
12 | class CommandFactory |
||
13 | { |
||
14 | /** |
||
15 | * @param $action |
||
16 | * @return Command |
||
17 | */ |
||
18 | public static function createFromAction($action): Command |
||
19 | { |
||
20 | $command = new Command(); |
||
21 | $command->setAction($action); |
||
22 | return $command; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param ServerRequestInterface|null $request |
||
27 | * @return Command |
||
28 | */ |
||
29 | public static function createFromRequest(ServerRequestInterface $request): Command |
||
30 | { |
||
31 | $command = new Command(); |
||
32 | $command->setRequest($request); |
||
33 | return $command; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param ForwardException $exception |
||
38 | * @return Command |
||
39 | */ |
||
40 | public static function createFromForwardException(ForwardException $exception) |
||
0 ignored issues
–
show
|
|||
41 | { |
||
42 | $command = new Command(); |
||
43 | return $command; |
||
44 | } |
||
45 | } |
||
46 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.