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

RecordEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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
}