Conditions | 11 |
Paths | 1 |
Total Lines | 26 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
50 | public function find(EventMatcherInterface $eventMatcher) : array |
||
51 | { |
||
52 | return array_filter($this->events, static function (EventInterface $event) use ($eventMatcher) { |
||
53 | $aggregateId = $eventMatcher->getAggregateId(); |
||
54 | $aggregateClass = $eventMatcher->getAggregateClass(); |
||
55 | $fromSequence = $eventMatcher->getSequence(); |
||
56 | $streamName = $eventMatcher->getStreamName(); |
||
57 | $timestamp = $eventMatcher->getTimestamp(); |
||
58 | |||
59 | $condition = true; |
||
60 | if (! empty($aggregateId)) { |
||
61 | $condition = $condition && ($event->getAggregateId() === $aggregateId); |
||
62 | } |
||
63 | if (! empty($aggregateClass)) { |
||
64 | $condition = $condition && ($event->getAggregateClass() === (string) $aggregateClass); |
||
65 | } |
||
66 | if (! empty($fromSequence)) { |
||
67 | $condition = $condition && ($event->getSequence() > $fromSequence); |
||
68 | } |
||
69 | if (! empty($streamName)) { |
||
70 | $condition = $condition && ($event->getStreamName() === (string) $streamName); |
||
71 | } |
||
72 | if (! empty($timestamp)) { |
||
73 | $condition = $condition && ($event->getTimestamp() > $timestamp); |
||
74 | } |
||
75 | return $condition; |
||
76 | }); |
||
79 |