RecordEvent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

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
 * 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