RequestParserChain::parse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 4
nc 3
nop 1
crap 3
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\RequestParser;
13
14
use PostmanGeneratorBundle\Model\Request;
15
16
class RequestParserChain implements RequestParserInterface
17
{
18
    /**
19
     * @var RequestParserInterface[]
20
     */
21
    private $parsers = [];
22
23
    /**
24
     * @param RequestParserInterface[] $parsers
25
     */
26 2
    public function __construct(array $parsers)
27
    {
28 2
        $this->parsers = $parsers;
29 2
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public function parse(Request $request)
35
    {
36 1
        foreach ($this->parsers as $parser) {
37 1
            if ($parser->supports($request)) {
38 1
                $parser->parse($request);
39 1
            }
40 1
        }
41 1
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function supports(Request $request)
47
    {
48 1
        return true;
49
    }
50
}
51