Passed
Push — master ( 2e1e94...ef92a5 )
by Gerrit
02:12
created

EntityInteractionEvent::getEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 20
    public function __construct(
50
        string $entityClass,
51
        string $entityId = null,
52
        $entity = null,
53
        string $method = null,
54
        array $arguments = array()
55
    ) {
56 20
        Assert::true(class_exists($entityClass));
57 20
        Assert::true(is_object($entity) || is_null($entity));
58
59 20
        $this->entityClass = $entityClass;
60 20
        $this->entityId = $entityId;
61 20
        $this->entity = $entity;
62 20
        $this->method = $method;
63 20
        $this->arguments = $arguments;
64 20
    }
65
66 1
    public function getEntityClass(): string
67
    {
68 1
        return $this->entityClass;
69
    }
70
71 1
    public function getEntityId(): ?string
72
    {
73 1
        return $this->entityId;
74
    }
75
76
    /**
77
     * @return object|null
78
     */
79 1
    public function getEntity()
80
    {
81 1
        return $this->entity;
82
    }
83
84 1
    public function getMethod(): ?string
85
    {
86 1
        return $this->method;
87
    }
88
89 1
    public function getArguments(): array
90
    {
91 1
        return $this->arguments;
92
    }
93
94
}
95