Passed
Push — main ( 85cf21...669ea3 )
by Slawomir
12:08 queued 07:21
created
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.
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
             }
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
     {
129 129
         return array_values(
130 130
             self::$tags
131
-                ->map(function ($tag) {
131
+                ->map(function($tag) {
132 132
                     return new TagDto($tag->getTag(), $this->countPosts($tag));
133
-                })->sort(function ($tag1, $tag2) {
133
+                })->sort(function($tag1, $tag2) {
134 134
                     return $tag1->getPostsCount() > $tag2->getPostsCount();
135 135
                 })->toArray()
136 136
         );
@@ -141,23 +141,23 @@  discard block
 block discarded – undo
141 141
         $from = ($pageNo - 1) * self::PAGE_SIZE;
142 142
         $to = $from + self::PAGE_SIZE;
143 143
         $size = self::$postHeaders
144
-            ->filter(function ($post) use ($tag) {
144
+            ->filter(function($post) use ($tag) {
145 145
                 return Collection::from($post->getTags())
146
-                        ->filter(function ($postTag) use ($tag) {
146
+                        ->filter(function($postTag) use ($tag) {
147 147
                             return $postTag->getTag() == $tag;
148 148
                         })
149 149
                         ->size() > 0;
150 150
             })->size();
151 151
         $data = array_values(self::$postHeaders
152
-            ->filter(function ($post) use ($tag) {
152
+            ->filter(function($post) use ($tag) {
153 153
                 return Collection::from($post->getTags())
154
-                        ->filter(function ($postTag) use ($tag) {
154
+                        ->filter(function($postTag) use ($tag) {
155 155
                             return $postTag->getTag() == $tag;
156 156
                         })
157 157
                         ->size() > 0;
158 158
             })
159 159
             ->slice($from, $to)
160
-            ->map(function ($header) {
160
+            ->map(function($header) {
161 161
                 return new TagsPostHeaderDto(
162 162
                     $header->getId(),
163 163
                     $header->getTitle(),
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                     $header->getVersion(),
169 169
                     $header->getCommentsCount(),
170 170
                     Collection::from($header->getTags())
171
-                        ->map(function ($tag) {
171
+                        ->map(function($tag) {
172 172
                             return $tag->getTag();
173 173
                         })
174 174
                         ->toArray()
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
     private function countPosts(InMemoryTag $tag): int
182 182
     {
183 183
         return self::$postHeaders
184
-            ->filter(function ($post) use ($tag) {
184
+            ->filter(function($post) use ($tag) {
185 185
                 return Collection::from($post->getTags())
186
-                        ->filter(function ($postTag) use ($tag) {
186
+                        ->filter(function($postTag) use ($tag) {
187 187
                             return $postTag->getTag() == $tag->getTag();
188 188
                         })
189 189
                         ->size() > 0;
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
     public function updatePostTags(Ulid $postId, array $tags): void
195 195
     {
196 196
         self::$postHeaders
197
-            ->filter(function ($post) use ($postId) {
197
+            ->filter(function($post) use ($postId) {
198 198
                 return $post->getId() == $postId;
199 199
             })
200
-            ->each(function ($post) {
200
+            ->each(function($post) {
201 201
                 $post->setTags([]);
202 202
             })->realize();
203 203
         foreach ($tags as $tag) {
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 
208 208
     private function addPostToTag(string $tag, Ulid $postId): void
209 209
     {
210
-        $tagObj = self::$tags->find(function ($tagObj) use ($tag) {
210
+        $tagObj = self::$tags->find(function($tagObj) use ($tag) {
211 211
             return $tagObj->getTag() == $tag;
212 212
         });
213 213
         if ($tagObj == null) {
214 214
             $tagObj = new InMemoryTag(new Ulid(), $tag);
215 215
             self::$tags = self::$tags->append($tagObj);
216 216
         }
217
-        $post = self::$postHeaders->find(function ($post) use ($postId) {
217
+        $post = self::$postHeaders->find(function($post) use ($postId) {
218 218
             return $post->getId() == $postId;
219 219
         });
220 220
         if ($post != null) {
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
             array_push($tags, $tagObj);
223 223
             $post->setTags($tags);
224 224
         } else {
225
-            throw new \RuntimeException("No Post Header: " . $postId);
225
+            throw new \RuntimeException("No Post Header: ".$postId);
226 226
         }
227 227
     }
228 228
 
229 229
     public function updatePostCommentsCount(UpdatePostsCommentsCountDto $commentsCount): void
230 230
     {
231 231
         self::$postHeaders
232
-            ->filter(function ($header) use ($commentsCount) {
232
+            ->filter(function($header) use ($commentsCount) {
233 233
                 return $header->getId() == $commentsCount->getPostId();
234 234
             })
235
-            ->each(function ($header) use ($commentsCount) {
235
+            ->each(function($header) use ($commentsCount) {
236 236
                 $header->setCommentsCount($commentsCount->getCommentsCount());
237 237
             })
238 238
             ->realize();
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
     public function updateUserName(UpdatedTagsPostHeadersUserNameDto $updatedUserName): void
242 242
     {
243 243
         self::$postHeaders
244
-            ->filter(function ($post) use ($updatedUserName) {
244
+            ->filter(function($post) use ($updatedUserName) {
245 245
                 return $post->getCreatedByName() == $updatedUserName->getOldUserName();
246 246
             })
247
-            ->each(function ($post) use ($updatedUserName) {
247
+            ->each(function($post) use ($updatedUserName) {
248 248
                 $post->setCreatedByName($updatedUserName->getNewUserName());
249 249
             })
250 250
             ->realize();
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     public function postExists(Ulid $postId): bool
254 254
     {
255 255
         return self::$postHeaders
256
-            ->filter(function ($post) use ($postId) {
256
+            ->filter(function($post) use ($postId) {
257 257
                 return $post->getId() == $postId;
258 258
             })->sizeIsGreaterThan(0);
259 259
     }
Please login to merge, or discard this patch.