1 | <?php |
||
18 | final class Commit implements CommitInterface |
||
19 | { |
||
20 | /** @var StreamId */ |
||
21 | private $streamId; |
||
22 | |||
23 | /** @var StreamRevision */ |
||
24 | private $streamRevision; |
||
25 | |||
26 | /** @var DomainEventSequence */ |
||
27 | private $eventLog; |
||
28 | |||
29 | /** @var Metadata */ |
||
30 | private $metadata; |
||
31 | |||
32 | public static function make( |
||
33 | StreamId $streamId, |
||
34 | StreamRevision $streamRevision, |
||
35 | DomainEventSequence $eventLog, |
||
36 | Metadata $metadata |
||
37 | ): CommitInterface { |
||
38 | return new self($streamId, $streamRevision, $eventLog, $metadata); |
||
39 | } |
||
40 | |||
41 | 1 | public static function fromArray(array $state): MessageInterface |
|
42 | { |
||
43 | 1 | return new self( |
|
44 | 1 | StreamId::fromNative($state['streamId']), |
|
|
|||
45 | 1 | StreamRevision::fromNative((int)$state['streamRevision']), |
|
46 | 1 | DomainEventSequence::fromArray($state['eventLog']), |
|
47 | 1 | Metadata::fromArray($state['metadata']) |
|
48 | ); |
||
49 | } |
||
50 | |||
51 | public function getStreamId(): StreamId |
||
55 | |||
56 | public function getStreamRevision(): StreamRevision |
||
57 | { |
||
58 | return $this->streamRevision; |
||
59 | } |
||
60 | |||
61 | public function getAggregateRevision(): AggregateRevision |
||
62 | { |
||
63 | return $this->eventLog->getHeadRevision(); |
||
64 | } |
||
65 | |||
66 | public function getEventLog(): DomainEventSequence |
||
67 | { |
||
68 | return $this->eventLog; |
||
69 | } |
||
70 | |||
71 | public function getMetadata(): Metadata |
||
75 | |||
76 | 1 | public function toArray(): array |
|
77 | { |
||
78 | return [ |
||
79 | 1 | '@type' => static::class, |
|
80 | 1 | 'streamId' => $this->streamId->toNative(), |
|
86 | |||
87 | 1 | private function __construct( |
|
98 | } |
||
99 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.