Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 12 | class StoredEventData implements Arrayable |
||
| 13 | { |
||
| 14 | /** @var int|null */ |
||
| 15 | public $id; |
||
| 16 | |||
| 17 | /** @var string */ |
||
| 18 | public $event_properties; |
||
| 19 | |||
| 20 | /** @var string */ |
||
| 21 | public $aggregate_uuid; |
||
| 22 | |||
| 23 | /** @var string */ |
||
| 24 | public $event_class; |
||
| 25 | |||
| 26 | /** @var array */ |
||
| 27 | public $meta_data; |
||
| 28 | |||
| 29 | /** @var \Carbon\Carbon */ |
||
| 30 | public $created_at; |
||
| 31 | |||
| 32 | /** @var \Spatie\EventProjector\ShouldBeStored|null */ |
||
| 33 | public $event; |
||
| 34 | |||
| 35 | public function __construct(array $data) |
||
| 53 | |||
| 54 | public function toArray() |
||
| 65 | |||
| 66 | public function handle() |
||
| 67 | { |
||
| 68 | Projectionist::handleWithSyncProjectors($this); |
||
| 69 | |||
| 70 | if (method_exists($this->event, 'tags')) { |
||
| 71 | $tags = $this->event->tags(); |
||
|
|
|||
| 72 | } |
||
| 73 | |||
| 74 | $storedEventJob = call_user_func( |
||
| 75 | [config('event-projector.stored_event_job'), 'createForEvent'], |
||
| 76 | $this, |
||
| 77 | $tags ?? [] |
||
| 78 | ); |
||
| 79 | |||
| 80 | dispatch($storedEventJob->onQueue($this->event->queue ?? config('event-projector.queue'))); |
||
| 81 | } |
||
| 82 | |||
| 83 | protected static function getActualClassForEvent(string $class): string |
||
| 87 | |||
| 88 | View Code Duplication | protected static function getEventClass(string $class): string |
|
| 98 | } |
||
| 99 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.