1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of cloak. |
5
|
|
|
* |
6
|
|
|
* (c) Noritaka Horio <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace cloak; |
13
|
|
|
|
14
|
|
|
use cloak\AnalyzedCoverageResult; |
15
|
|
|
use cloak\AnalyzerConfiguration; |
16
|
|
|
use cloak\Reporter\Reporter; |
17
|
|
|
use cloak\event\InitializeEvent; |
18
|
|
|
use cloak\event\AnalyzeStartEvent; |
19
|
|
|
use cloak\event\AnalyzeStopEvent; |
20
|
|
|
use PHPExtra\EventManager\EventManager; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class AnalyzeLifeCycleNotifier |
25
|
|
|
* @package cloak |
26
|
|
|
*/ |
27
|
|
|
class AnalyzeLifeCycleNotifier implements LifeCycleNotifier |
28
|
|
|
{ |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \PHPExtra\EventManager\EventManager |
32
|
|
|
*/ |
33
|
|
|
private $manager; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param Reporter $reporter |
37
|
|
|
*/ |
38
|
|
|
public function __construct(Reporter $reporter = null) |
39
|
|
|
{ |
40
|
|
|
$eventManager = new EventManager(); |
41
|
|
|
$eventManager->setThrowExceptions(true); |
42
|
|
|
|
43
|
|
|
$this->setEventManager($eventManager); |
44
|
|
|
|
45
|
|
|
if ($reporter === null) { |
46
|
|
|
return; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$reporter->registerTo( $this->getEventManager() ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function setEventManager(EventManager $manager) |
53
|
|
|
{ |
54
|
|
|
$this->manager = $manager; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getEventManager() |
58
|
|
|
{ |
59
|
|
|
return $this->manager; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function notifyInitialize(AnalyzerConfiguration $configuration) |
63
|
|
|
{ |
64
|
|
|
$event = new InitializeEvent($configuration); |
65
|
|
|
$this->getEventManager()->emit($event); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function notifyStart() |
69
|
|
|
{ |
70
|
|
|
$event = new AnalyzeStartEvent(); |
71
|
|
|
$this->getEventManager()->emit($event); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param AnalyzedCoverageResult $result |
76
|
|
|
*/ |
77
|
|
|
public function notifyStop(AnalyzedCoverageResult $result) |
78
|
|
|
{ |
79
|
|
|
$event = new AnalyzeStopEvent($result); |
80
|
|
|
$this->getEventManager()->emit($event); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
|