EventManagerVariant   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 7
c 2
b 0
f 2
lcom 1
cbo 1
dl 0
loc 66
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getEventManager() 0 4 1
A getIdentifier() 0 4 1
A getEventName() 0 4 1
A getCallback() 0 4 1
A getPriority() 0 4 1
A run() 0 4 1
1
<?php
2
/**
3
 * This file is part of phpab/phpab-module. (https://github.com/phpab/phpab-module)
4
 *
5
 * @link https://github.com/phpab/phpab-module for the canonical source repository
6
 * @copyright Copyright (c) 2015-2016 phpab. (https://github.com/phpab/)
7
 * @license https://raw.githubusercontent.com/phpab/phpab-module/master/LICENSE MIT
8
 */
9
10
namespace PhpAbModule\Variant;
11
12
use PhpAb\Variant\VariantInterface;
13
use Zend\EventManager\EventManagerInterface;
14
use Zend\ServiceManager\FactoryInterface;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17
class EventManagerVariant implements VariantInterface
18
{
19
    /**
20
     * @var EventManagerInterface
21
     */
22
    private $eventManager;
23
24
    /**
25
     * @var string
26
     */
27
    private $idenfier;
28
29
    /**
30
     * @var string
31
     */
32
    private $eventName;
33
34
    /**
35
     * @var callable
36
     */
37
    private $callback;
38
39
    /**
40
     * @var int
41
     */
42
    private $priority;
43
44
    public function __construct(EventManagerInterface $eventManager, $identifier, $eventName, $callback, $priority)
0 ignored issues
show
Unused Code introduced by
The parameter $priority is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        $this->eventManager = $eventManager;
47
        $this->idenfier = $identifier;
48
        $this->eventName = $eventName;
49
        $this->callback = $callback;
50
        $this->priority = 0;
51
    }
52
53
    public function getEventManager()
54
    {
55
        return $this->eventManager;
56
    }
57
58
    public function getIdentifier()
59
    {
60
        return $this->idenfier;
61
    }
62
63
    public function getEventName()
64
    {
65
        return $this->eventName;
66
    }
67
68
    public function getCallback()
69
    {
70
        return $this->callback;
71
    }
72
73
    public function getPriority()
74
    {
75
        return $this->priority;
76
    }
77
78
    public function run()
79
    {
80
        $this->getEventManager()->attach($this->getEventName(), $this->getCallback(), $this->getPriority());
81
    }
82
}
83