Completed
Push — output_parsers_refactor ( ea70d9...668933 )
by Alessandro
02:32
created

ProcessOutputParser   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 7
Bugs 1 Features 1
Metric Value
wmc 6
c 7
b 1
f 1
lcom 1
cbo 2
dl 0
loc 38
ccs 0
cts 20
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addParser() 0 4 1
A getParsers() 0 4 1
A onProcessTerminated() 0 8 3
1
<?php
2
3
namespace Paraunit\Parser;
4
5
use Paraunit\Lifecycle\ProcessEvent;
6
7
/**
8
 * Class ProcessOutputParser.
9
 */
10
class ProcessOutputParser
11
{
12
    /** @var JSONParserChainElementInterface[] */
13
    protected $parsers;
14
15
    public function __construct()
16
    {
17
        $this->parsers = array();
18
    }
19
20
    /**
21
     * @param JSONParserChainElementInterface $parser
22
     */
23
    public function addParser(JSONParserChainElementInterface $parser)
24
    {
25
        $this->parsers[] = $parser;
26
    }
27
28
    /**
29
     * @return JSONParserChainElementInterface[]
30
     */
31
    public function getParsers()
32
    {
33
        return $this->parsers;
34
    }
35
36
    /**
37
     * @param ProcessEvent $processEvent
38
     */
39
    public function onProcessTerminated(ProcessEvent $processEvent)
40
    {
41
        foreach ($this->parsers as $parser) {
42
            if ( ! $parser->parsingFoundResult($processEvent->getProcess())) {
0 ignored issues
show
Bug introduced by
The call to parsingFoundResult() misses a required argument $log.

This check looks for function calls that miss required arguments.

Loading history...
43
                return;
44
            }
45
        }
46
    }
47
}
48