Passed
Push — main ( 0b8455...908887 )
by Slawomir
04:53
created
tests/TestUtils/Transaction/InMemoryTransaction.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * @return mixed
28 28
      * @throws \Exception
29 29
      */
30
-   public function execute(): mixed
30
+    public function execute(): mixed
31 31
     {
32 32
         try {
33 33
             $handler = $this->func;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param $func
54 54
      * @return $this
55 55
      */
56
-   public function afterCommit($func): TransactionInterface
56
+    public function afterCommit($func): TransactionInterface
57 57
     {
58 58
         $this->afterCommit = $this->afterCommit->append($func);
59 59
         return $this;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @param $func
64 64
      * @return $this
65 65
      */
66
-   public function afterRollback($func): TransactionInterface
66
+    public function afterRollback($func): TransactionInterface
67 67
     {
68 68
         $this->afterRollback = $this->afterRollback->append($func);
69 69
         return $this;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@
 block discarded – undo
33 33
             $handler = $this->func;
34 34
             $result = $handler();
35 35
             $this->afterCommit
36
-                ->each(function ($successFn) use ($result) {
36
+                ->each(function($successFn) use ($result) {
37 37
                     $successFn($result);
38 38
                 })
39 39
                 ->realize();
40 40
             return $result;
41 41
         } catch (\Exception $e) {
42 42
             $this->afterRollback
43
-                ->each(function ($rollbackFn) {
43
+                ->each(function($rollbackFn) {
44 44
                     $rollbackFn();
45 45
                 })
46 46
                 ->realize();
Please login to merge, or discard this patch.
tests/TestUtils/Events/InMemoryEventPublisher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     {
39 39
         return array_values(
40 40
             InMemoryEventPublisher::$publishedEvents
41
-                ->filter(function ($event) use ($eventClass) {
41
+                ->filter(function($event) use ($eventClass) {
42 42
                     return $event::class == $eventClass;
43 43
                 })
44 44
                 ->toArray()
Please login to merge, or discard this patch.
tests/Modules/Tags/Unit/Repository/InMemoryTagsRepository.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     public function updatePostHeader(UpdateExistingTagsPostHeaderDto $updatedPostHeader): void
63 63
     {
64 64
         self::$postHeaders
65
-            ->filter(function ($header) use ($updatedPostHeader) {
65
+            ->filter(function($header) use ($updatedPostHeader) {
66 66
                 return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion();
67 67
             })
68
-            ->each(function ($header) use ($updatedPostHeader) {
68
+            ->each(function($header) use ($updatedPostHeader) {
69 69
                 $header->setTitle($updatedPostHeader->getTitle());
70 70
                 $header->setSummary($updatedPostHeader->getSummary());
71 71
                 $header->setVersion($updatedPostHeader->getVersion());
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     public function deletePostHeader(DeleteExistingTagsPostHeaderDto $deletedPostHeader): void
76 76
     {
77 77
         self::$postHeaders = self::$postHeaders->filter(
78
-            function ($header) use ($deletedPostHeader) {
78
+            function($header) use ($deletedPostHeader) {
79 79
                 return $header->getId() != $deletedPostHeader->getId();
80 80
             }
81 81
         )->realize();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     public function findPostHeaders(): array
85 85
     {
86 86
         return self::$postHeaders
87
-            ->map(function ($header) {
87
+            ->map(function($header) {
88 88
                 return new TagsPostHeaderDto(
89 89
                     $header->getId(),
90 90
                     $header->getTitle(),
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                     $header->getVersion(),
96 96
                     $header->getCommentsCount(),
97 97
                     Collection::from($header->getTags())
98
-                        ->map(function ($tag) {
98
+                        ->map(function($tag) {
99 99
                             return $tag->getTag();
100 100
                         })
101 101
                         ->toArray()
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     {
109 109
         $usedTagIds = $this->findUsedTagIds();
110 110
         self::$tags = self::$tags
111
-            ->filter(function ($tag) use ($usedTagIds) {
111
+            ->filter(function($tag) use ($usedTagIds) {
112 112
                 return $usedTagIds->contains($tag->getTag());
113 113
             })->realize();
114 114
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     private function findUsedTagIds(): ArrayCollection
117 117
     {
118 118
         $usedTags = new ArrayCollection();
119
-        self::$postHeaders->each(function ($post) use ($usedTags) {
119
+        self::$postHeaders->each(function($post) use ($usedTags) {
120 120
             foreach ($post->getTags() as $tag) {
121 121
                 $usedTags->add($tag->getTag());
122 122
             }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function findTags(): array
128 128
     {
129
-        return array_values(self::$tags->map(function ($tag) {
129
+        return array_values(self::$tags->map(function($tag) {
130 130
             return new TagDto($tag->getTag(), $this->countPosts($tag));
131
-        })->sort(function ($tag1, $tag2) {
131
+        })->sort(function($tag1, $tag2) {
132 132
             return $tag1->getPostsCount() > $tag2->getPostsCount();
133 133
         })->toArray());
134 134
     }
@@ -138,23 +138,23 @@  discard block
 block discarded – undo
138 138
         $from = ($pageNo - 1) * self::PAGE_SIZE;
139 139
         $to = $from + self::PAGE_SIZE;
140 140
         $size = self::$postHeaders
141
-            ->filter(function ($post) use ($tag) {
141
+            ->filter(function($post) use ($tag) {
142 142
                 return Collection::from($post->getTags())
143
-                        ->filter(function ($postTag) use ($tag) {
143
+                        ->filter(function($postTag) use ($tag) {
144 144
                             return $postTag->getTag() == $tag->getTag();
145 145
                         })
146 146
                         ->size() > 0;
147 147
             })->size();
148 148
         $data = array_values(self::$postHeaders
149
-            ->filter(function ($post) use ($tag) {
149
+            ->filter(function($post) use ($tag) {
150 150
                 return Collection::from($post->getTags())
151
-                        ->filter(function ($postTag) use ($tag) {
151
+                        ->filter(function($postTag) use ($tag) {
152 152
                             return $postTag->getTag() == $tag->getTag();
153 153
                         })
154 154
                         ->size() > 0;
155 155
             })
156 156
             ->slice($from, $to)
157
-            ->map(function ($header) {
157
+            ->map(function($header) {
158 158
                 return new TagsPostHeaderDto(
159 159
                     $header->getId(),
160 160
                     $header->getTitle(),
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                     $header->getVersion(),
166 166
                     $header->getCommentsCount(),
167 167
                     Collection::from($header->getTags())
168
-                        ->map(function ($tag) {
168
+                        ->map(function($tag) {
169 169
                             return $tag->getTag();
170 170
                         })
171 171
                         ->toArray()
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     private function countPosts(InMemoryTag $tag): int
179 179
     {
180 180
         return self::$postHeaders
181
-            ->filter(function ($post) use ($tag) {
181
+            ->filter(function($post) use ($tag) {
182 182
                 return Collection::from($post->getTags())
183
-                        ->filter(function ($postTag) use ($tag) {
183
+                        ->filter(function($postTag) use ($tag) {
184 184
                             return $postTag->getTag() == $tag->getTag();
185 185
                         })
186 186
                         ->size() > 0;
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
     public function updatePostTags(Ulid $postId, array $tags): void
192 192
     {
193 193
         self::$postHeaders
194
-            ->filter(function ($post) use ($postId) {
194
+            ->filter(function($post) use ($postId) {
195 195
                 return $post->getId() == $postId;
196 196
             })
197
-            ->each(function ($post) {
197
+            ->each(function($post) {
198 198
                 $post->setTags([]);
199 199
             })->realize();
200 200
         foreach ($tags as $tag) {
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 
205 205
     private function addPostToTag(string $tag, Ulid $postId): void
206 206
     {
207
-        $tagObj = self::$tags->find(function ($tagObj) use ($tag) {
207
+        $tagObj = self::$tags->find(function($tagObj) use ($tag) {
208 208
             return $tagObj->getTag() == $tag;
209 209
         });
210 210
         if ($tagObj == null) {
211 211
             $tagObj = new InMemoryTag(new Ulid(), $tag);
212 212
             self::$tags = self::$tags->append($tagObj);
213 213
         }
214
-        $post = self::$postHeaders->find(function ($post) use ($postId) {
214
+        $post = self::$postHeaders->find(function($post) use ($postId) {
215 215
             return $post->getId() == $postId;
216 216
         });
217 217
         if ($post != null) {
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
             array_push($tags, $tagObj);
220 220
             $post->setTags($tags);
221 221
         } else {
222
-            throw new \RuntimeException("No Post Header: " . $postId);
222
+            throw new \RuntimeException("No Post Header: ".$postId);
223 223
         }
224 224
     }
225 225
 
226 226
     public function updatePostCommentsCount(UpdatePostsCommentsCountDto $commentsCount): void
227 227
     {
228 228
         self::$postHeaders
229
-            ->filter(function ($header) use ($commentsCount) {
229
+            ->filter(function($header) use ($commentsCount) {
230 230
                 return $header->getId() == $commentsCount->getPostId();
231 231
             })
232
-            ->each(function ($header) use ($commentsCount) {
232
+            ->each(function($header) use ($commentsCount) {
233 233
                 $header->setCommentsCount($commentsCount->getCommentsCount());
234 234
             })
235 235
             ->realize();
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
     public function updateUserName(UpdatedTagsPostHeadersUserNameDto $updatedUserName): void
239 239
     {
240 240
         self::$postHeaders
241
-            ->filter(function ($post) use ($updatedUserName) {
241
+            ->filter(function($post) use ($updatedUserName) {
242 242
                 return $post->getCreatedByName() == $updatedUserName->getOldUserName();
243 243
             })
244
-            ->each(function ($post) use ($updatedUserName) {
244
+            ->each(function($post) use ($updatedUserName) {
245 245
                 $post->setCreatedByName($updatedUserName->getNewUserName());
246 246
             })
247 247
             ->realize();
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     public function postExists(Ulid $postId): bool
251 251
     {
252 252
         return self::$postHeaders
253
-            ->filter(function ($post) use ($postId) {
253
+            ->filter(function($post) use ($postId) {
254 254
                 return $post->getId() == $postId;
255 255
             })->sizeIsGreaterThan(0);
256 256
     }
Please login to merge, or discard this patch.
tests/Modules/Comments/Unit/Repository/InMemoryCommentsRepository.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
     public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void
54 54
     {
55 55
         self::$postHeaders
56
-            ->filter(function ($header) use ($updatedPostHeader) {
56
+            ->filter(function($header) use ($updatedPostHeader) {
57 57
                 return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion();
58 58
             })
59
-            ->each(function ($header) use ($updatedPostHeader) {
59
+            ->each(function($header) use ($updatedPostHeader) {
60 60
                 $header->setTitle($updatedPostHeader->getTitle());
61 61
                 $header->setTags($updatedPostHeader->getTags());
62 62
                 $header->setVersion($updatedPostHeader->getVersion());
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     public function deletePostHeader(DeleteExistingCommentsPostHeaderDto $deletedPostHeader): void
68 68
     {
69 69
         self::$postHeaders = self::$postHeaders->filter(
70
-            function ($header) use ($deletedPostHeader) {
70
+            function($header) use ($deletedPostHeader) {
71 71
                 return $header->getId() != $deletedPostHeader->getId();
72 72
             }
73 73
         )->realize();
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
     public function findPostHeaders(?\DateTime $from = null): array
77 77
     {
78 78
         return self::$postHeaders
79
-            ->filter(function ($header) use ($from) {
79
+            ->filter(function($header) use ($from) {
80 80
                 return $from == null || $header->getCreatedAt() >= $from;
81 81
             })
82
-            ->map(function ($header) {
82
+            ->map(function($header) {
83 83
                 return new CommentsPostHeaderDto(
84 84
                     $header->getId(),
85 85
                     $header->getTitle(),
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
         $id = new Ulid();
96 96
         $parentComment = null;
97 97
         if ($newComment->getParentId() != null) {
98
-            $parentComment = self::$comments->find(function ($comment) use ($newComment) {
98
+            $parentComment = self::$comments->find(function($comment) use ($newComment) {
99 99
                 return $comment->getId() == $newComment->getParentId();
100 100
             });
101 101
         }
102
-        $post = self::$postHeaders->find(function ($post) use ($newComment) {
102
+        $post = self::$postHeaders->find(function($post) use ($newComment) {
103 103
             return $post->getId() == $newComment->getPostId();
104 104
         });
105 105
         $comment = new InMemoryComment(
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
     public function getCommentsCount(Ulid $postId): int
121 121
     {
122 122
         return self::$postHeaders
123
-            ->filter(function ($post) use ($postId) {
123
+            ->filter(function($post) use ($postId) {
124 124
                 return $post->getId() == $postId;
125 125
             })
126
-            ->map(function ($post) {
126
+            ->map(function($post) {
127 127
                 return count($post->getComments());
128 128
             })
129 129
             ->first();
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
     public function findCommentsByPostId(Ulid $postId): array
133 133
     {
134 134
         $post = self::$postHeaders
135
-            ->find(function ($post) use ($postId) {
135
+            ->find(function($post) use ($postId) {
136 136
                 return $post->getId() == $postId;
137 137
             });
138 138
         if ($post == null) {
139 139
             return [];
140 140
         }
141 141
         return Collection::from($post->getComments())
142
-            ->map(function ($comment) {
142
+            ->map(function($comment) {
143 143
                 $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null;
144 144
                 return new CommentDto(
145 145
                     $comment->getId(),
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         $from = ($pageNo - 1) * self::PAGE_SIZE;
157 157
         $to = $from + self::PAGE_SIZE;
158 158
         $data = self::$comments
159
-            ->map(function ($comment) {
159
+            ->map(function($comment) {
160 160
                 $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null;
161 161
                 return new CommentWithPostDto(
162 162
                     $comment->getId(),
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
                 );
172 172
             })
173
-            ->sort(function ($c1, $c2) {
173
+            ->sort(function($c1, $c2) {
174 174
                 return $c1->getCreatedAt() < $c2->getCreatedAt() ? 1 : -1;
175 175
             })
176 176
             ->slice($from, $to)
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     public function commentExists(Ulid $commentId): bool
182 182
     {
183 183
         return self::$comments
184
-            ->filter(function ($comment) use ($commentId) {
184
+            ->filter(function($comment) use ($commentId) {
185 185
                 return $comment->getId() == $commentId;
186 186
             })->sizeIsGreaterThan(0);
187 187
     }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     public function postExists(Ulid $postId): bool
190 190
     {
191 191
         return self::$postHeaders
192
-            ->filter(function ($post) use ($postId) {
192
+            ->filter(function($post) use ($postId) {
193 193
                 return $post->getId() == $postId;
194 194
             })->sizeIsGreaterThan(0);
195 195
     }
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
     public function deleteCommentsForPost(Ulid $postId)
198 198
     {
199 199
         self::$comments = self::$comments
200
-            ->filter(function ($comment) use ($postId) {
200
+            ->filter(function($comment) use ($postId) {
201 201
                 return $comment->getPost()->getId() != $postId;
202 202
             })
203 203
             ->realize();
204
-        $post = self::$postHeaders->find(function ($post) use ($postId) {
204
+        $post = self::$postHeaders->find(function($post) use ($postId) {
205 205
             $post->getId() == $postId;
206 206
         });
207 207
         if ($post != null) {
Please login to merge, or discard this patch.
tests/Modules/Posts/Unit/Repository/InMemoryPostsRepository.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         self::$posts = Collection::from(
67 67
             self::$posts
68
-                ->filter(function ($post) use ($dto) {
68
+                ->filter(function($post) use ($dto) {
69 69
                     return $post->getId() != $dto->getId();
70 70
                 })
71 71
                 ->toArray()
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
     public function updatePost(UpdateExistingPostDto $dto): void
76 76
     {
77 77
         self::$posts
78
-            ->filter(function ($post) use ($dto) {
78
+            ->filter(function($post) use ($dto) {
79 79
                 return $post->getId() == $dto->getId();
80 80
             })
81
-            ->each(function ($post) use ($dto) {
81
+            ->each(function($post) use ($dto) {
82 82
                 $post->setTitle($dto->getTitle());
83 83
                 $post->setBody($dto->getBody());
84 84
                 $post->setSummary($dto->getSummary());
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
     public function findPost(Ulid $id): ?PostDto
93 93
     {
94
-        $found = self::$posts->find(function ($post) use ($id) {
94
+        $found = self::$posts->find(function($post) use ($id) {
95 95
             return $post->getId() == $id;
96 96
         });
97 97
         return $found == null ? null : new PostDto(
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         $to = $from + self::PAGE_SIZE;
115 115
         $data = self::$posts
116 116
             ->slice($from, $to)
117
-            ->map(function ($item) {
117
+            ->map(function($item) {
118 118
                 return new PostHeaderDto(
119 119
                     $item->getId(),
120 120
                     $item->getTitle(),
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
     public function updateAllComments(UpdatePostCommentsDto $updatedComments, bool $append = true): void
134 134
     {
135
-        $post = self::$posts->find(function ($post) use ($updatedComments) {
135
+        $post = self::$posts->find(function($post) use ($updatedComments) {
136 136
             return $post->getId() == $updatedComments->getPostId();
137 137
         });
138 138
         if ($post == null) {
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
     public function updateUserName(UpdatedPostsUserNameDto $updatedUserName): void
166 166
     {
167 167
         self::$posts
168
-            ->filter(function ($post) use ($updatedUserName) {
168
+            ->filter(function($post) use ($updatedUserName) {
169 169
                 return $post->getCreatedByName() == $updatedUserName->getOldUserName();
170 170
             })
171
-            ->each(function ($post) use ($updatedUserName) {
171
+            ->each(function($post) use ($updatedUserName) {
172 172
                 $post->setCreatedByName($updatedUserName->getNewUserName());
173 173
             })
174 174
             ->realize();
Please login to merge, or discard this patch.
src/Infrastructure/Doctrine/Transactions/DoctrineTransaction.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         try {
37 37
             $result = $this->entityManager->wrapInTransaction($this->func);
38 38
             $this->afterCommit
39
-                ->each(function ($successFn) use ($result) {
39
+                ->each(function($successFn) use ($result) {
40 40
                     $successFn($result);
41 41
                 })
42 42
                 ->realize();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             return $result;
45 45
         } catch (\Exception $e) {
46 46
             $this->afterRollback
47
-                ->each(function ($rollbackFn) {
47
+                ->each(function($rollbackFn) {
48 48
                     $rollbackFn();
49 49
                 })
50 50
                 ->realize();
Please login to merge, or discard this patch.