CommandParserChain   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 47
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 0 8 3
A execute() 0 8 3
A supports() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the PostmanGeneratorBundle package.
5
 *
6
 * (c) Vincent Chalamon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PostmanGeneratorBundle\CommandParser;
13
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class CommandParserChain implements CommandParserInterface
18
{
19
    /**
20
     * @var CommandParserInterface[]
21
     */
22
    private $parsers = [];
23
24
    /**
25
     * @param CommandParserInterface[] $parsers
26
     */
27 5
    public function __construct(array $parsers)
28
    {
29 5
        $this->parsers = $parsers;
30 5
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 2
    public function parse(InputInterface $input, OutputInterface $output)
36
    {
37 2
        foreach ($this->parsers as $parser) {
38 2
            if ($parser->supports()) {
39 1
                $parser->parse($input, $output);
40 1
            }
41 2
        }
42 2
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 2
    public function execute(InputInterface $input, OutputInterface $output)
48
    {
49 2
        foreach ($this->parsers as $parser) {
50 2
            if ($parser->supports()) {
51 1
                $parser->execute($input, $output);
52 1
            }
53 2
        }
54 2
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 1
    public function supports()
60
    {
61 1
        return true;
62
    }
63
}
64