Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | trait EventBehaviour |
||
24 | { |
||
25 | /** |
||
26 | * @var \ArrayObject<string, Event>|null |
||
27 | */ |
||
28 | private $recordedEvents; |
||
29 | |||
30 | /** |
||
31 | * Record event. |
||
32 | * |
||
33 | * @param Event $event |
||
34 | */ |
||
35 | final protected function recordEvent(Event $event): void |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | final public function getRecordedEvents(): EventCollection |
||
48 | { |
||
49 | return new EventIteratorCollection( |
||
50 | $this->recordedEvents !== null ? $this->recordedEvents->getIterator() : new \EmptyIterator() |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | final public function clearRecordedEvents(): void |
||
58 | { |
||
59 | $this->recordedEvents = null; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | final public function collectRecordedEvents(): EventCollection |
||
74 | } |
||
75 | } |
||
76 |