DetailListOfLineParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A parse() 0 22 3
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2017-04-07
5
 */
6
7
namespace Net\Bazzline\Component\ApacheServerStatusParser\Service\Content\Parser;
8
9
use InvalidArgumentException;
10
use Net\Bazzline\Component\ApacheServerStatusParser\DomainModel\Detail;
11
12
class DetailListOfLineParser implements ListOfLineParserInterface
13
{
14
    /** @var DetailLineParser */
15
    private $detailLineParser;
16
17
    /**
18
     * DetailListOfLineParser constructor.
19
     *
20
     * @param DetailLineParser $detailLineParser
21
     */
22
    public function __construct(
23
        DetailLineParser $detailLineParser
24
    ) {
25
        $this->detailLineParser = $detailLineParser;
26
    }
27
28
    /**
29
     * @param string[] $listOfLine
30
     *
31
     * @return Detail[]
32
     * @throws InvalidArgumentException
33
     */
34
    public function parse(array $listOfLine)
35
    {
36
        //begin of dependencies
37
        $detailLineParser           = $this->detailLineParser;
38
        $listOfParsedDetailLines    = [];
39
        //end of dependencies
40
41
        //begin of business logic
42
        foreach ($listOfLine as $line) {
43
            try {
44
                $listOfParsedDetailLines[] = $detailLineParser->parse($line);
45
            } catch (InvalidArgumentException $invalidArgumentException) {
46
                //@todo
47
                //echo get_class($detailLineParser) . ' could not parse the following line:' . PHP_EOL;
48
                //echo '    ' . $line . PHP_EOL;
49
                //echo $invalidArgumentException->getMessage() . PHP_EOL;
50
            }
51
        }
52
53
        return $listOfParsedDetailLines;
54
        //end of business logic
55
    }
56
}
57