Completed
Push — develop ( c86111...2faf16 )
by ANTHONIUS
21s
created

CoverageEvent   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 62
ccs 10
cts 14
cp 0.7143
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addException() 0 6 2
A getTestCase() 0 3 1
A getProcessor() 0 3 1
A __construct() 0 3 1
A setTestCase() 0 3 1
A setProcessor() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the doyo/behat-coverage-extension project.
5
 *
6
 * (c) Anthonius Munthi <[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
declare(strict_types=1);
13
14
namespace Doyo\Behat\Coverage\Event;
15
16
use Doyo\Behat\Coverage\Bridge\CodeCoverage\ProcessorInterface;
17
use Doyo\Behat\Coverage\Bridge\CodeCoverage\TestCase;
18
use Doyo\Behat\Coverage\Bridge\Symfony\Event;
19
20
class CoverageEvent extends Event
21
{
22
    const BEFORE_START   = 'doyo.coverage.start.pre';
23
    const BEFORE_STOP    = 'doyo.coverage.stop.pre';
24
    const BEFORE_REFRESH = 'doyo.coverage.refresh.pre';
25
    const START          = 'doyo.coverage.start';
26
    const STOP           = 'doyo.coverage.stop';
27
    const REFRESH        = 'doyo.coverage.refresh';
28
    const COMPLETED      = 'doyo.coverage.completed';
29
30
    /**
31
     * @var TestCase
32
     */
33
    private $testCase;
34
35
    /**
36
     * @var ProcessorInterface
37
     */
38
    private $processor;
39
40
    /**
41
     * @var \Exception[]
42
     */
43
    private $exceptions;
44
45 6
    public function __construct(TestCase $testCase = null)
46
    {
47 6
        $this->testCase   = $testCase;
48
    }
49
50
    /**
51
     * @return TestCase
52
     */
53 6
    public function getTestCase()
54
    {
55 6
        return $this->testCase;
56
    }
57
58
    /**
59
     * @param TestCase $testCase
60
     */
61 7
    public function setTestCase($testCase=null)
62
    {
63 7
        $this->testCase = $testCase;
64
    }
65
66 8
    public function setProcessor($processor)
67
    {
68 8
        $this->processor = $processor;
69
    }
70
71 1
    public function getProcessor()
72
    {
73 1
        return $this->processor;
74
    }
75
76
    public function addException(\Exception $exception)
77
    {
78
        $id = md5($exception->getMessage());
79
80
        if (!isset($this->exceptions[$id])) {
81
            $this->exceptions[$id] = $exception;
82
        }
83
    }
84
}
85