| Conditions | 4 |
| Paths | 6 |
| Total Lines | 33 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function replayEvents(Collection $projectors) |
||
| 12 | { |
||
| 13 | $afterEventId = $this->determineAfterEventId($projectors); |
||
| 14 | |||
| 15 | if ($afterEventId === StoredEvent::getMaxId()) { |
||
| 16 | $this->warn('There are no events to replay.'); |
||
|
|
|||
| 17 | } |
||
| 18 | |||
| 19 | $replayEventsCount = StoredEvent::after($afterEventId)->count(); |
||
| 20 | |||
| 21 | if ($replayEventsCount === 0) { |
||
| 22 | $this->warn('There are no events to replay'); |
||
| 23 | |||
| 24 | return; |
||
| 25 | } |
||
| 26 | |||
| 27 | $afterEventId === 0 |
||
| 28 | ? $this->comment('Replaying all events...') |
||
| 29 | : $this->comment("Replaying events after stored event id {$afterEventId}..."); |
||
| 30 | $this->emptyLine(); |
||
| 31 | |||
| 32 | $bar = $this->output->createProgressBar(StoredEvent::after($afterEventId)->count()); |
||
| 33 | $onEventReplayed = function () use ($bar) { |
||
| 34 | $bar->advance(); |
||
| 35 | }; |
||
| 36 | |||
| 37 | $this->eventProjectionist->replayEvents($projectors, $afterEventId, $onEventReplayed); |
||
| 38 | |||
| 39 | $bar->finish(); |
||
| 40 | |||
| 41 | $this->emptyLine(2); |
||
| 42 | $this->comment('All done!'); |
||
| 43 | } |
||
| 44 | |||
| 67 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.