Passed
Push — main ( ed1bb6...4383ba )
by Slawomir
04:39
created
src/Modules/Comments/Domain/Logic/PostHeadersFinder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     public function findPostHeaders(): array
24 24
     {
25 25
         return Collection::from($this->headersFindingRepository->findPostHeaders())
26
-            ->map(function ($header) {
26
+            ->map(function($header) {
27 27
                 return new FindCommentsPostHeadersQueryResponse(
28 28
                     $header->getId(),
29 29
                     $header->getTitle(),
Please login to merge, or discard this patch.
src/Modules/Tags/Domain/Logic/CommentsEventsHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
    public function onCommentsCountUpdated(CommentsCountUpdatedTagsIEvent $event): void
28 28
     {
29 29
         $this->transactionFactory
30
-            ->createTransaction(function () use ($event) {
30
+            ->createTransaction(function() use ($event) {
31 31
                 $this->commentsEventHandlingRepository->updatePostCommentsCount(
32 32
                     new UpdatePostsCommentsCountDto($event->getPostId(), $event->getCommentsCount())
33 33
                 );
Please login to merge, or discard this patch.
src/Modules/Tags/Domain/Logic/PostHeadersFinder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     public function findPostHeaders(): array
27 27
     {
28 28
         return Collection::from($this->headersFindingRepository->findPostHeaders())
29
-            ->map(function ($header) {
29
+            ->map(function($header) {
30 30
                 return new FindTagsPostHeadersQueryResponse(
31 31
                     $header->getId(),
32 32
                     $header->getTitle(),
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $page = $this->headersFindingRepository->findPostHeadersByTag($query->getTag(), $query->getPageNo());
51 51
         $data = Collection::from($page->getData())
52
-            ->map(function ($header) {
52
+            ->map(function($header) {
53 53
                 return new FindPostsByTagQueryResponse(
54 54
                     $header->getId(),
55 55
                     $header->getTitle(),
Please login to merge, or discard this patch.
src/Infrastructure/Utils/StringUtil.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
         if ($body === null) {
15 15
             return "";
16 16
         }
17
-        $short = strlen($body) - 1 < $maxLength ? $body : trim(substr($body, 0, $maxLength)). "...";
18
-        return strip_tags($short) ;;
17
+        $short = strlen($body) - 1 < $maxLength ? $body : trim(substr($body, 0, $maxLength))."...";
18
+        return strip_tags($short); ;
19 19
     }
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/Comments/Domain/Logic/CommentsValidator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     private function validatePostExists(Ulid $postId): void
40 40
     {
41
-        if(!$this->postHeadersFindingRepository->postExists($postId)) {
41
+        if (!$this->postHeadersFindingRepository->postExists($postId)) {
42 42
             throw new BadRequestHttpException("Requested Post doesn't exist");
43 43
         }
44 44
     }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     private function validateCommentExists(Ulid $commentId): void
50 50
     {
51
-        if(!$this->commentsFindingRepository->commentExists($commentId)) {
51
+        if (!$this->commentsFindingRepository->commentExists($commentId)) {
52 52
             throw new BadRequestHttpException("Requested Parent Comment doesn't exist");
53 53
         }
54 54
     }
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,14 +126,14 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function addPostToTag(string $tag, Ulid $postId): void
128 128
     {
129
-        $tagObj = self::$tags->find(function ($tagObj) use ($tag) {
129
+        $tagObj = self::$tags->find(function($tagObj) use ($tag) {
130 130
             return $tagObj->getTag() == $tag;
131 131
         });
132 132
         if ($tagObj == null) {
133 133
             $tagObj = new InMemoryTag(new Ulid(), $tag);
134 134
             self::$tags = self::$tags->append($tagObj);
135 135
         }
136
-        $post = self::$postHeaders->find(function ($post) use ($postId) {
136
+        $post = self::$postHeaders->find(function($post) use ($postId) {
137 137
             return $post->getId() == $postId;
138 138
         });
139 139
         if ($post != null) {
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
             array_push($tags, $tagObj);
142 142
             $post->setTags($tags);
143 143
         } else {
144
-            throw new \RuntimeException("No Post Header: " . $postId);
144
+            throw new \RuntimeException("No Post Header: ".$postId);
145 145
         }
146 146
     }
147 147
 
148 148
     public function findTags(): array
149 149
     {
150
-        return array_values(self::$tags->map(function ($tag) {
150
+        return array_values(self::$tags->map(function($tag) {
151 151
             return new TagDto($tag->getTag(), $this->countPosts($tag));
152
-        })->sort(function ($tag1, $tag2) {
152
+        })->sort(function($tag1, $tag2) {
153 153
             return $tag1->getPostsCount() > $tag2->getPostsCount();
154 154
         })->toArray());
155 155
     }
@@ -159,23 +159,23 @@  discard block
 block discarded – undo
159 159
         $from = ($pageNo - 1) * self::PAGE_SIZE;
160 160
         $to = $from + self::PAGE_SIZE;
161 161
         $size = self::$postHeaders
162
-            ->filter(function ($post) use ($tag) {
162
+            ->filter(function($post) use ($tag) {
163 163
                 return Collection::from($post->getTags())
164
-                        ->filter(function ($postTag) use ($tag) {
164
+                        ->filter(function($postTag) use ($tag) {
165 165
                             return $postTag->getTag() == $tag->getTag();
166 166
                         })
167 167
                         ->size() > 0;
168 168
             })->size();
169 169
         $data = array_values(self::$postHeaders
170
-            ->filter(function ($post) use ($tag) {
170
+            ->filter(function($post) use ($tag) {
171 171
                 return Collection::from($post->getTags())
172
-                        ->filter(function ($postTag) use ($tag) {
172
+                        ->filter(function($postTag) use ($tag) {
173 173
                             return $postTag->getTag() == $tag->getTag();
174 174
                         })
175 175
                         ->size() > 0;
176 176
             })
177 177
             ->slice($from, $to)
178
-            ->map(function ($header) {
178
+            ->map(function($header) {
179 179
                 return new TagsPostHeaderDto(
180 180
                     $header->getId(),
181 181
                     $header->getTitle(),
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                     $header->getVersion(),
187 187
                     $header->getCommentsCount(),
188 188
                     Collection::from($header->getTags())
189
-                        ->map(function ($tag) {
189
+                        ->map(function($tag) {
190 190
                             return $tag->getTag();
191 191
                         })
192 192
                         ->toArray()
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
     private function countPosts(InMemoryTag $tag): int
200 200
     {
201 201
         return self::$postHeaders
202
-            ->filter(function ($post) use ($tag) {
202
+            ->filter(function($post) use ($tag) {
203 203
                 return Collection::from($post->getTags())
204
-                        ->filter(function ($postTag) use ($tag) {
204
+                        ->filter(function($postTag) use ($tag) {
205 205
                             return $postTag->getTag() == $tag->getTag();
206 206
                         })
207 207
                         ->size() > 0;
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
     public function removePostFromTags(Ulid $postId): void
213 213
     {
214 214
         self::$postHeaders
215
-            ->filter(function ($post) use ($postId) {
215
+            ->filter(function($post) use ($postId) {
216 216
                 return $post->getId() == $postId;
217 217
             })
218
-            ->each(function ($post) {
218
+            ->each(function($post) {
219 219
                 $post->setTags([]);
220 220
             })->realize();
221 221
     }
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
     public function updatePostCommentsCount(UpdatePostsCommentsCountDto $commentsCount): void
224 224
     {
225 225
         self::$postHeaders
226
-            ->filter(function ($header) use ($commentsCount) {
226
+            ->filter(function($header) use ($commentsCount) {
227 227
                 return $header->getId() == $commentsCount->getPostId();
228 228
             })
229
-            ->each(function ($header) use ($commentsCount) {
229
+            ->each(function($header) use ($commentsCount) {
230 230
                 $header->setCommentsCount($commentsCount->getCommentsCount());
231 231
             })
232 232
             ->realize();
@@ -235,10 +235,10 @@  discard block
 block discarded – undo
235 235
     public function updateUserName(UpdatedTagsPostHeadersUserNameDto $updatedUserName): void
236 236
     {
237 237
         self::$postHeaders
238
-            ->filter(function ($post) use ($updatedUserName) {
238
+            ->filter(function($post) use ($updatedUserName) {
239 239
                 return $post->getCreatedByName() == $updatedUserName->getOldUserName();
240 240
             })
241
-            ->each(function ($post) use ($updatedUserName) {
241
+            ->each(function($post) use ($updatedUserName) {
242 242
                 $post->setCreatedByName($updatedUserName->getNewUserName());
243 243
             })
244 244
             ->realize();
Please login to merge, or discard this patch.
tests/Modules/Tags/Integration/Http/TagsHttpTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     public function findPostByTag(FindPostsByTagQuery $query): Page
32 32
     {
33 33
         $client = $this->getClient();
34
-        $client->request('GET', '/api/tags/' . $query->getTag());
34
+        $client->request('GET', '/api/tags/'.$query->getTag());
35 35
         return $this->responseObject($client, Page::class);
36 36
     }
37 37
 
Please login to merge, or discard this patch.
tests/Modules/Posts/Unit/Repository/InMemoryPostsRepository.php 1 patch
Spacing   +7 added lines, -7 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,7 +75,7 @@  discard block
 block discarded – undo
75 75
    public function updatePost(UpdateExistingPostDto $dto): void
76 76
     {
77 77
         foreach (self::$posts
78
-                     ->filter(function ($post) use ($dto) {
78
+                     ->filter(function($post) use ($dto) {
79 79
                          return $post->getId() == $dto->getId();
80 80
                      })
81 81
                      ->toArray() as $post) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
     public function findPost(Ulid $id): ?PostDto
92 92
     {
93
-        $found = self::$posts->find(function ($post) use ($id) {
93
+        $found = self::$posts->find(function($post) use ($id) {
94 94
             return $post->getId() == $id;
95 95
         });
96 96
         return $found == null ? null : new PostDto(
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 
131 131
     public function updateAllComments(UpdatePostCommentsDto $updatedComments, bool $append = true): void
132 132
     {
133
-        $post = self::$posts->find(function ($post) use ($updatedComments) {
133
+        $post = self::$posts->find(function($post) use ($updatedComments) {
134 134
             return $post->getId() == $updatedComments->getPostId();
135 135
         });
136 136
         if ($post == null) {
137 137
             throw new \RuntimeException("Unable to Find Post For Comment");
138 138
         }
139
-        if($append) {
139
+        if ($append) {
140 140
             $data = $post->getComments();
141 141
             foreach ($updatedComments->getComments() as $newComment) {
142 142
                 array_push($data, $newComment);
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
     public function updateUserName(UpdatedPostsUserNameDto $updatedUserName): void
164 164
     {
165 165
         self::$posts
166
-            ->filter(function ($post) use ($updatedUserName) {
166
+            ->filter(function($post) use ($updatedUserName) {
167 167
                 return $post->getCreatedByName() == $updatedUserName->getOldUserName();
168 168
             })
169
-            ->each(function ($post) use ($updatedUserName) {
169
+            ->each(function($post) use ($updatedUserName) {
170 170
                 $post->setCreatedByName($updatedUserName->getNewUserName());
171 171
             })
172 172
             ->realize();
Please login to merge, or discard this patch.
tests/Modules/Posts/Integration/Http/PostsHttpTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,25 +26,25 @@
 block discarded – undo
26 26
 
27 27
     public function updatePost(UpdatePostCommand $command): void
28 28
     {
29
-        $this->getClient()->request('PUT', '/api/admin/posts/' . $command->getId(), [], [], [], $this->json($command));
29
+        $this->getClient()->request('PUT', '/api/admin/posts/'.$command->getId(), [], [], [], $this->json($command));
30 30
     }
31 31
 
32 32
     public function deletePost(DeletePostCommand $command): void
33 33
     {
34
-        $this->getClient()->request('DELETE', '/api/admin/posts/' . $command->getId());
34
+        $this->getClient()->request('DELETE', '/api/admin/posts/'.$command->getId());
35 35
     }
36 36
 
37 37
     public function findAllPosts(FindAllPostsQuery $query): Page
38 38
     {
39 39
         $client = $this->getClient();
40
-        $client->request('GET', '/api/posts/?pageNo=' . $query->getPageNo());
40
+        $client->request('GET', '/api/posts/?pageNo='.$query->getPageNo());
41 41
         return $this->responseObject($client, Page::class);
42 42
     }
43 43
 
44 44
     public function findPostById(FindPostByIdQuery $query): FindPostQueryResponse
45 45
     {
46 46
         $client = $this->getClient();
47
-        $client->request('GET', '/api/posts/' . $query->getId());
47
+        $client->request('GET', '/api/posts/'.$query->getId());
48 48
         return $this->responseObject($client, FindPostQueryResponse::class);
49 49
     }
50 50
 
Please login to merge, or discard this patch.