RecordEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Spiral, Core Components
4
 *
5
 * @author Wolfy-J
6
 */
7
8
namespace Spiral\ORM\Events;
9
10
use Spiral\Models\EntityInterface;
11
use Spiral\Models\Events\EntityEvent;
12
use Spiral\ORM\CommandInterface;
13
use Spiral\ORM\ContextualCommandInterface;
14
15
class RecordEvent extends EntityEvent
16
{
17
    /**
18
     * @var CommandInterface
19
     */
20
    private $command;
21
22
    /**
23
     * @param EntityInterface  $entity
24
     * @param CommandInterface $command
25
     */
26
    public function __construct(EntityInterface $entity, CommandInterface $command)
27
    {
28
        parent::__construct($entity);
29
        $this->command = $command;
30
    }
31
32
    /**
33
     * Indication that command is contextual (i.e. have mutable data).
34
     *
35
     * @return bool
36
     */
37
    public function isContextual(): bool
38
    {
39
        return $this->command instanceof ContextualCommandInterface;
40
    }
41
42
    /**
43
     * @return CommandInterface
44
     */
45
    public function getCommand(): CommandInterface
46
    {
47
        return $this->command;
48
    }
49
}
50