AnalyzeLifeCycleNotifier   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 7
c 6
b 0
f 0
lcom 1
cbo 5
dl 0
loc 57
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
A setEventManager() 0 4 1
A getEventManager() 0 4 1
A notifyInitialize() 0 5 1
A notifyStart() 0 5 1
A notifyStop() 0 5 1
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