Morebec / OrkestraMono

Orkestra is a library of infrastructure and architecture helpers for creating CQRS/ES/DDD applications
Apache License 2.0
2 stars 0 forks source link

[EventSourcing] UpcastringEventStoreDecorator does not test for support before upcasting #6

Closed jwillp closed 2 years ago

jwillp commented 2 years ago

There is the following code:

    /**
     * Upcast an event and returns the result as an array as when upcasting an event might
     * have been split into many new ones.
     */
    private function upcastEvent(RecordedEventDescriptor $event): array
    {
        // Here a test to see if the upcasterChain supports the event should be performed

        return $this->upcasterChain->upcast(UpcastableEventDescriptor::fromRecordedEventDescriptor($event));
    }

And also in the UpcasterChain:

 if (empty($chain)) {
            return [$event];
        }

        $head = \array_slice($chain, 0, 1);
        $tail = \array_slice($chain, 1);

        // SHOULD BE TESTED here again

        $events = $head[0]->upcast($event);