Passed
Push — dev_2x ( 3e8772...896177 )
by Adrian
06:45
created

SavingEntity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 32
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntity() 0 3 1
A eventName() 0 3 1
A setEntity() 0 3 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Orm\Event;
5
6
use League\Event\HasEventName;
7
use Sirius\Orm\Contract\EntityInterface;
8
use Sirius\Orm\Query;
9
10
class SavingEntity implements HasEventName
11
{
12
13
    /**
14
     * @var string
15
     */
16
    private $mapper;
17
18
    /**
19
     * @var EntityInterface
20
     */
21
    private $entity;
22
23
    public function __construct(string $mapper, EntityInterface $entity)
24
    {
25
        $this->mapper = $mapper;
26
        $this->entity = $entity;
27
    }
28
29
    public function getEntity(): EntityInterface
30
    {
31
        return $this->entity;
32
    }
33
34
    public function setEntity(EntityInterface $entity)
35
    {
36
        $this->entity = $entity;
37
    }
38
39
    public function eventName(): string
40
    {
41
        return $this->mapper . '.saving';
42
    }
43
}
44