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

EngineEvent::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2.0625
1
<?php
2
3
namespace Paraunit\Lifecycle;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
use Symfony\Component\EventDispatcher\Event;
7
8
/***
9
 * Class EngineEvent
10
 * @package Paraunit\Lifecycle
11
 */
12
class EngineEvent extends Event
13
{
14
    // This Event will be triggered before the whole paraunit engine is started
15
    const BEFORE_START = 'engine_event.before_start';
16
17
    // This Event will be triggered when paraunit finished building the process stack
18
    const START = 'engine_event.start';
19
20
    // This Event will be triggered when paraunit finished all test execution
21
    const END = 'engine_event.end';
22
23
    /** @var  OutputInterface */
24
    protected $outputInterface;
25
26
    /** @var  array */
27
    protected $context;
28
29
    /**
30
     * @param OutputInterface $outputInterface
31
     * @param array           $context
32
     */
33 9
    public function __construct(OutputInterface $outputInterface, $context = array())
34
    {
35 9
        $this->outputInterface = $outputInterface;
36 9
        $this->context = $context;
37 9
    }
38
39
    /**
40
     * @return OutputInterface
41
     */
42 9
    public function getOutputInterface()
43
    {
44 9
        return $this->outputInterface;
45
    }
46
47
    /**
48
     * @param $contextParameterName
49
     *
50
     * @return bool
51
     */
52 9
    public function has($contextParameterName)
53
    {
54 9
        return isset($this->context[$contextParameterName]);
55
    }
56
57
    /**
58
     * @param $contextParameterName
59
     *
60
     * @return mixed
61
     */
62 9
    public function get($contextParameterName)
63
    {
64 9
        if (!$this->has($contextParameterName)) {
65
            throw new \LogicException('Cannot find parameter: '.$contextParameterName);
66
        }
67
68 9
        return $this->context[$contextParameterName];
69
    }
70
}
71