Passed
Push — master ( 261f35...f81515 )
by Gerrit
09:50
created

EntityInteractionEvent   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 47.37%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 77
ccs 9
cts 19
cp 0.4737
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
A getEntityClass() 0 4 1
A getEntityId() 0 4 1
A getEntity() 0 4 1
A getMethod() 0 4 1
A getArguments() 0 4 1
1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 *
8
 * @license GPL-3.0
9
 *
10
 * @author Gerrit Addiks <[email protected]>
11
 */
12
13
namespace Addiks\SymfonyGenerics\Events;
14
15
use Symfony\Component\EventDispatcher\Event;
16
use Webmozart\Assert\Assert;
17
18
final class EntityInteractionEvent extends Event
19
{
20
21
    /**
22
     * @var string
23
     */
24
    private $entityClass;
25
26
    /**
27
     * @var string|null
28
     */
29
    private $entityId;
30
31
    /**
32
     * @var object|null
33
     */
34
    private $entity;
35
36
    /**
37
     * @var string|null
38
     */
39
    private $method;
40
41
    /**
42
     * @var array
43
     */
44
    private $arguments;
45
46
    /**
47
     * @param object|null $entity
48
     */
49 10
    public function __construct(
50
        string $entityClass,
51
        string $entityId = null,
52
        $entity = null,
53
        string $method = null,
54
        array $arguments = array()
55
    ) {
56 10
        Assert::true(class_exists($entityClass));
57 10
        Assert::true(is_object($entity) || is_null($entity));
58
59 10
        $this->entityClass = $entityClass;
60 10
        $this->entityId = $entityId;
61 10
        $this->entity = $entity;
62 10
        $this->method = $method;
63 10
        $this->arguments = $arguments;
64 10
    }
65
66
    public function getEntityClass(): string
67
    {
68
        return $this->entityClass;
69
    }
70
71
    public function getEntityId(): ?string
72
    {
73
        return $this->entityId;
74
    }
75
76
    /**
77
     * @return object|null
78
     */
79
    public function getEntity()
80
    {
81
        return $this->entity;
82
    }
83
84
    public function getMethod(): ?string
85
    {
86
        return $this->method;
87
    }
88
89
    public function getArguments(): array
90
    {
91
        return $this->arguments;
92
    }
93
94
}
95