CommandFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 32
ccs 0
cts 11
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromAction() 0 5 1
A createFromRequest() 0 5 1
A createFromForwardException() 0 4 1
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
Unused Code introduced by
The parameter $exception is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    public static function createFromForwardException(/** @scrutinizer ignore-unused */ ForwardException $exception)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        $command = new Command();
43
        return $command;
44
    }
45
}
46