EntityEvent   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 108
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getName() 0 4 1
A getEntity() 0 4 1
A getData() 0 4 1
A setData() 0 4 1
A getErrors() 0 4 1
A setErrors() 0 4 1
A getValidData() 0 7 2
A setValidData() 0 4 1
1
<?php
2
3
namespace T4web\DomainModule;
4
5
use Zend\EventManager\Event;
6
use T4webDomainInterface\EntityInterface;
7
use T4webDomainInterface\EventInterface;
8
9
class EntityEvent extends Event implements EventInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $name;
15
16
    /**
17
     * @var EntityInterface
18
     */
19
    protected $entity;
20
21
    /**
22
     * @var array
23
     */
24
    protected $data = [];
25
26
    /**
27
     * @var array
28
     */
29
    protected $validData = [];
30
31
    /**
32
     * @var array
33
     */
34
    protected $errors = [];
35
36
    /**
37
     * EntityEvent constructor.
38
     * @param string $name
39
     * @param EntityInterface $entity
40
     * @param array $data
41
     */
42
    public function __construct($name, EntityInterface $entity = null, array $data = [])
43
    {
44
        $this->name = $name;
45
        $this->entity = $entity;
46
        $this->data = $data;
47
        $this->validData = $data;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getName()
54
    {
55
        return $this->name;
56
    }
57
58
    /**
59
     * @return EntityInterface
60
     */
61
    public function getEntity()
62
    {
63
        return $this->entity;
64
    }
65
66
    /**
67
     * @return array
68
     */
69
    public function getData()
70
    {
71
        return $this->data;
72
    }
73
74
    /**
75
     * @param array $data
76
     */
77
    public function setData($data)
78
    {
79
        $this->data = $data;
80
    }
81
82
    /**
83
     * @return array
84
     */
85
    public function getErrors()
86
    {
87
        return $this->errors;
88
    }
89
90
    /**
91
     * @param array $errors
92
     */
93
    public function setErrors(array $errors)
94
    {
95
        $this->errors = $errors;
96
    }
97
98
    /**
99
     * @return array
100
     */
101
    public function getValidData()
102
    {
103
        if (!empty($this->errors)) {
104
            return [];
105
        }
106
        return $this->validData;
107
    }
108
109
    /**
110
     * @param array $validData
111
     */
112
    public function setValidData($validData)
113
    {
114
        $this->validData = $validData;
115
    }
116
}
117