TemporaryPlugin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 4
Bugs 0 Features 2
Metric Value
c 4
b 0
f 2
dl 0
loc 30
wmc 3
lcom 0
cbo 4
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerTo() 0 4 1
A onSuiteStart() 0 9 1
A create() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of peridot-temporary-plugin.
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 holyshared\peridot\temporary;
13
14
use Peridot\Core\Suite;
15
use Evenement\EventEmitterInterface;
16
17
18
/**
19
 * TemporaryPlugin
20
 * @package holyshared\peridot\temporary
21
 */
22
class TemporaryPlugin implements Registrar
23
{
24
25
    /**
26
     * @param EventEmitterInterface $emitter
27
     */
28
    public function registerTo(EventEmitterInterface $emitter)
29
    {
30
        $emitter->on(self::START_EVENT, [ $this, 'onSuiteStart' ]);
31
    }
32
33
    /**
34
     * @param Suite $suite
35
     */
36
    public function onSuiteStart(Suite $suite)
37
    {
38
        $scope = new TemporaryScope();
39
        $suite->getScope()->peridotAddChildScope($scope);
40
41
        $suite->addTearDownFunction(function () use(&$scope) {
42
            $scope->cleanUpTemporary();
43
        });
44
    }
45
46
    public static function create()
47
    {
48
        return new self();
49
    }
50
51
}
52