SymfonyCli   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 58.81%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 73
ccs 10
cts 17
cp 0.5881
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A match() 0 14 4
A assemble() 0 4 1
A getAssembledParams() 0 4 1
A factory() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Mvc\Router\Console;
6
7
use BadMethodCallException;
8
use Laminas\Console\Request as ConsoleRequest;
9
use Laminas\Mvc\Console\Router\RouteInterface;
10
use Laminas\Router\RouteMatch;
11
use Laminas\Stdlib\RequestInterface as Request;
12
use Symfony\Component\Console\Application;
13
14
/**
15
 * Route matching commands in Symfony CLI
16
 */
17
class SymfonyCli implements RouteInterface
18
{
19
    /** @var Application */
20
    protected $cliApplication;
21
22
    /**
23
     * Default values.
24
     *
25
     * @var mixed[]
26
     */
27
    protected $defaults;
28
29
    /**
30
     * Constructor
31
     *
32
     * @param mixed[] $defaults
33
     */
34 3
    public function __construct(Application $cliApplication, array $defaults = [])
35
    {
36 3
        $this->cliApplication = $cliApplication;
37 3
        $this->defaults       = $defaults;
38 3
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43 3
    public function match(Request $request)
44
    {
45 3
        if (! $request instanceof ConsoleRequest) {
46
            return null;
47
        }
48
49 3
        $params = $request->getParams()->toArray();
50
51 3
        if (! isset($params[0]) || ! $this->cliApplication->has($params[0])) {
52 1
            return null;
53
        }
54
55 2
        return new RouteMatch($this->defaults);
56
    }
57
58
    /**
59
     * Disabled.
60
     *
61
     * {@inheritDoc}
62
     *
63
     * @throws BadMethodCallException this method is disabled.
64
     */
65
    public function assemble(array $params = [], array $options = [])
66
    {
67
        throw new BadMethodCallException('Unsupported');
68
    }
69
70
    /**
71
     * {@inheritDoc}
72
     */
73
    public function getAssembledParams()
74
    {
75
        return [];
76
    }
77
78
    /**
79
     * Disabled.
80
     *
81
     * {@inheritDoc}
82
     *
83
     * @throws BadMethodCallException this method is disabled.
84
     */
85
    public static function factory($options = [])
86
    {
87
        throw new BadMethodCallException('Unsupported');
88
    }
89
}
90