Passed
Push — main ( ee4c89...151aaf )
by Slawomir
04:06
created
tests/Modules/Comments/Unit/Repository/InMemoryCommentsRepository.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void
56 56
     {
57 57
         foreach (self::$postHeaders
58
-                     ->filter(function ($header) use ($updatedPostHeader) {
58
+                     ->filter(function($header) use ($updatedPostHeader) {
59 59
                          return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion();
60 60
                      })
61 61
                      ->toArray() as $header) {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function deletePostHeader(DeleteExistingCommentsPostHeaderDto $deletedPostHeader): void
69 69
     {
70 70
         self::$postHeaders = self::$postHeaders->filter(
71
-           function ($header) use ($deletedPostHeader) {
71
+           function($header) use ($deletedPostHeader) {
72 72
                 return $header->getId() != $deletedPostHeader->getId();
73 73
             }
74 74
         )->realize();
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
     public function findPostHeaders(?\DateTime $from = null): array
78 78
     {
79 79
         return self::$postHeaders
80
-            ->filter(function ($header) use ($from) {
80
+            ->filter(function($header) use ($from) {
81 81
                 return $from == null || $header->getCreatedAt() >= $from;
82 82
             })
83
-            ->map(function ($header) {
83
+            ->map(function($header) {
84 84
                 return new CommentsPostHeaderDto(
85 85
                     $header->getId(),
86 86
                     $header->getTitle(),
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
         $id = new Ulid();
97 97
         $parentComment = null;
98 98
         if ($newComment->getParentId() != null) {
99
-            $parentComment = self::$comments->find(function ($comment) use ($newComment) {
99
+            $parentComment = self::$comments->find(function($comment) use ($newComment) {
100 100
                 return $comment->getId() == $newComment->getParentId();
101 101
             });
102 102
         }
103
-        $post = self::$postHeaders->find(function ($post) use ($newComment) {
103
+        $post = self::$postHeaders->find(function($post) use ($newComment) {
104 104
             return $post->getId() == $newComment->getPostId();
105 105
         });
106 106
         $comment = new InMemoryComment(
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
     public function getCommentsCount(Ulid $postId): int
122 122
     {
123 123
         return self::$postHeaders
124
-            ->filter(function ($post) use ($postId) {
124
+            ->filter(function($post) use ($postId) {
125 125
                 return $post->getId() == $postId;
126 126
             })
127
-            ->map(function ($post) {
127
+            ->map(function($post) {
128 128
                 return count($post->getComments());
129 129
             })
130 130
             ->first();
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
     public function findCommentsByPostId(Ulid $postId): array
134 134
     {
135 135
         $post = self::$postHeaders
136
-            ->find(function ($post) use ($postId) {
136
+            ->find(function($post) use ($postId) {
137 137
                 return $post->getId() == $postId;
138 138
             });
139 139
         if ($post == null) {
140 140
             return [];
141 141
         }
142 142
         return Collection::from($post->getComments())
143
-            ->map(function ($comment) {
143
+            ->map(function($comment) {
144 144
                 $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null;
145 145
                 return new CommentDto(
146 146
                     $comment->getId(),
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         $from = ($pageNo - 1) * self::PAGE_SIZE;
158 158
         $to = $from + self::PAGE_SIZE;
159 159
         $data = self::$comments
160
-            ->map(function ($comment) {
160
+            ->map(function($comment) {
161 161
                 $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null;
162 162
                 return new CommentWithPostDto(
163 163
                     $comment->getId(),
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
                 );
173 173
             })
174
-            ->sort(function ($c1, $c2) {
174
+            ->sort(function($c1, $c2) {
175 175
                 return $c1->getCreatedAt() < $c2->getCreatedAt() ? 1 : -1;
176 176
             })
177 177
             ->slice($from, $to)
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     public function commentExists(Ulid $commentId): bool
183 183
     {
184 184
         return self::$comments
185
-            ->filter(function ($comment) use ($commentId) {
185
+            ->filter(function($comment) use ($commentId) {
186 186
                 return $comment->getId() == $commentId;
187 187
             })->sizeIsGreaterThan(0);
188 188
     }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     public function postExists(Ulid $postId): bool
191 191
     {
192 192
         return self::$postHeaders
193
-            ->filter(function ($post) use ($postId) {
193
+            ->filter(function($post) use ($postId) {
194 194
                 return $post->getId() == $postId;
195 195
             })->sizeIsGreaterThan(0);
196 196
     }
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
     public function deleteCommentsForPost(Ulid $postId)
199 199
     {
200 200
         self::$comments = self::$comments
201
-            ->filter(function ($comment) use ($postId) {
201
+            ->filter(function($comment) use ($postId) {
202 202
                 return $comment->getPost()->getId() != $postId;
203 203
             })
204 204
             ->realize();
205
-        $post = self::$postHeaders->find(function ($post) use ($postId) {
205
+        $post = self::$postHeaders->find(function($post) use ($postId) {
206 206
             $post->getId() == $postId;
207 207
         });
208 208
         if ($post != null) {
Please login to merge, or discard this patch.
Doctrine/Repository/DoctrineCommentsPostHeadersFindingRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
         $dtoClass = CommentsPostHeaderDto::class;
20 20
         $dql = "select new $dtoClass(p.id, p.title, p.tags, p.version) from $headerClass p";
21 21
         if ($from != null) {
22
-            $dql = $dql . " where p.createdAt >= :from";
22
+            $dql = $dql." where p.createdAt >= :from";
23 23
         }
24 24
         $query = $this->getEntityManager()->createQuery($dql);
25 25
         if ($from != null) {
Please login to merge, or discard this patch.
src/Infrastructure/Events/ApplicationInboundEvent.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         if ($value == null) {
103 103
             return null;
104 104
         }
105
-        return is_string($value) ? $value : (string)$value;
105
+        return is_string($value) ? $value : (string) $value;
106 106
     }
107 107
 
108 108
     /**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             if ($nullable) {
117 117
                 return null;
118 118
             }
119
-            $name = call_user_func(get_called_class() . '::getName');
119
+            $name = call_user_func(get_called_class().'::getName');
120 120
             throw new RuntimeException("Event $name requires a field '$fieldName' to be present");
121 121
         }
122 122
         return $this->data[$fieldName];
Please login to merge, or discard this patch.
src/Infrastructure/Events/Api/EventHandlerReference.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
     public function getEventName(): string
41 41
     {
42
-        return call_user_func($this->inboundEventClass . '::getName');
42
+        return call_user_func($this->inboundEventClass.'::getName');
43 43
     }
44 44
 
45 45
 
Please login to merge, or discard this patch.
src/Modules/Posts/Api/Event/Inbound/UserRenamedPostsIEvent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      */
18 18
     public function __construct(array $data)
19 19
     {
20
-        parent::__construct( $data);
20
+        parent::__construct($data);
21 21
         $this->oldLogin = $this->string('oldLogin');
22 22
         $this->newLogin = $this->string('newLogin');
23 23
     }
Please login to merge, or discard this patch.
src/Modules/Posts/Api/Event/Inbound/CommentCreatedPostsIEvent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
      */
19 19
     public function __construct(array $data)
20 20
     {
21
-        parent::__construct( $data);
21
+        parent::__construct($data);
22 22
         $this->postId = $this->ulid('postId');
23 23
         $this->comments = [$this->array('comment')];
24 24
     }
Please login to merge, or discard this patch.
Posts/Persistence/Doctrine/Repository/DoctrinePostsFindingRepository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                     p.id, p.title, p.body, p.summary, p.tags, p.updatedAt, p.version
84 84
              ) from $postClass p where p.deletedAt is null";
85 85
         if ($from != null) {
86
-            $dql = $dql . " and p.createdAt >= :from";
86
+            $dql = $dql." and p.createdAt >= :from";
87 87
         }
88 88
         $query = $this->getEntityManager()->createQuery(
89 89
             $dql
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $postClass = Post::class;
104 104
         $dql = "select p.id as postId from $postClass p where p.deletedAt is not null";
105 105
         if ($from != null) {
106
-            $dql = $dql . " and p.deletedAt >= :from";
106
+            $dql = $dql." and p.deletedAt >= :from";
107 107
         }
108 108
         $query = $this->getEntityManager()->createQuery(
109 109
             $dql
Please login to merge, or discard this patch.
src/Infrastructure/Events/Api/ApplicationEventSubscriber.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     )
23 23
     {
24 24
         $this->subscribedHandlers = Collection::from($this->subscribe())
25
-            ->map(function ($handlerMethodName, $eventClass) {
25
+            ->map(function($handlerMethodName, $eventClass) {
26 26
                 return EventHandlerReference::create($handlerMethodName, $eventClass);
27 27
             })
28 28
             ->realize();
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     {
59 59
         return $this
60 60
             ->subscribedHandlers
61
-            ->filter(function ($ref) use ($event) {
61
+            ->filter(function($ref) use ($event) {
62 62
                 return $ref->getEventName() == $event->getName();
63
-            })->map(function ($value) {
63
+            })->map(function($value) {
64 64
                 return $value;
65 65
             })->toArray();
66 66
     }
Please login to merge, or discard this patch.
tests/Modules/Tags/Unit/Repository/InMemoryTagsRepository.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     public function updatePostHeader(UpdateExistingTagsPostHeaderDto $updatedPostHeader): void
63 63
     {
64 64
         foreach (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 68
                      ->toArray() as $header) {
@@ -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();
Please login to merge, or discard this patch.