Passed
Push — main ( 79e4f1...ed1bb6 )
by Slawomir
04:28
created
tests/Modules/Comments/Unit/Repository/InMemoryCommentsRepository.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  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) {
59
-                         return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion();
60
-                     })
61
-                     ->toArray() as $header) {
58
+                        ->filter(function ($header) use ($updatedPostHeader) {
59
+                            return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion();
60
+                        })
61
+                        ->toArray() as $header) {
62 62
             $header->setTitle($updatedPostHeader->getTitle());
63 63
             $header->setTags($updatedPostHeader->getTags());
64 64
             $header->setVersion($updatedPostHeader->getVersion());
@@ -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();
Please login to merge, or discard this 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.