Completed
Branch feature/pre-split (289154)
by Anton
03:22
created

RecordEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isContextual() 0 4 1
A getCommand() 0 4 1
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\ORM\Events;
8
9
use Spiral\Models\EntityInterface;
10
use Spiral\Models\Events\EntityEvent;
11
use Spiral\ORM\CommandInterface;
12
use Spiral\ORM\ContextualCommandInterface;
13
14
class RecordEvent extends EntityEvent
15
{
16
    /**
17
     * @var CommandInterface
18
     */
19
    private $command;
20
21
    public function __construct(EntityInterface $entity, CommandInterface $command)
22
    {
23
        parent::__construct($entity);
24
        $this->command = $command;
25
    }
26
27
    /**
28
     * Indication that command is contextual (i.e. have mutable data).
29
     *
30
     * @return bool
31
     */
32
    public function isContextual(): bool
33
    {
34
        return $this->command instanceof ContextualCommandInterface;
35
    }
36
37
    /**
38
     * @return CommandInterface
39
     */
40
    public function getCommand(): CommandInterface
41
    {
42
        return $this->command;
43
    }
44
}