ProjectsEvents   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A reset() 0 8 2
A shouldBeCalledImmediately() 0 4 1
1
<?php
2
3
namespace Spatie\EventSourcing\Projectors;
4
5
use Spatie\EventSourcing\EventHandlers\HandlesEvents;
6
use Spatie\EventSourcing\Exceptions\CouldNotResetProjector;
7
8
trait ProjectsEvents
9
{
10
    use HandlesEvents;
11
12
    public function getName(): string
13
    {
14
        return $this->name ?? get_class($this);
15
    }
16
17
    /** @deprecated Use reset state instead */
18
    public function reset(): void
19
    {
20
        if (! method_exists($this, 'resetState')) {
21
            throw CouldNotResetProjector::doesNotHaveResetStateMethod($this);
22
        }
23
24
        $this->resetState();
25
    }
26
27
    public function shouldBeCalledImmediately(): bool
28
    {
29
        return ! $this instanceof QueuedProjector;
30
    }
31
}
32