@@ -53,10 +53,10 @@ |
||
53 | 53 | public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void |
54 | 54 | { |
55 | 55 | foreach (self::$postHeaders |
56 | - ->filter(function ($header) use ($updatedPostHeader) { |
|
57 | - return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion(); |
|
58 | - }) |
|
59 | - ->toArray() as $header) { |
|
56 | + ->filter(function ($header) use ($updatedPostHeader) { |
|
57 | + return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion(); |
|
58 | + }) |
|
59 | + ->toArray() as $header) { |
|
60 | 60 | $header->setTitle($updatedPostHeader->getTitle()); |
61 | 61 | $header->setTags($updatedPostHeader->getTags()); |
62 | 62 | $header->setVersion($updatedPostHeader->getVersion()); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void |
54 | 54 | { |
55 | 55 | foreach (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 | 59 | ->toArray() as $header) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function deletePostHeader(DeleteExistingCommentsPostHeaderDto $deletedPostHeader): void |
67 | 67 | { |
68 | 68 | self::$postHeaders = self::$postHeaders->filter( |
69 | - function ($header) use ($deletedPostHeader) { |
|
69 | + function($header) use ($deletedPostHeader) { |
|
70 | 70 | return $header->getId() != $deletedPostHeader->getId(); |
71 | 71 | } |
72 | 72 | )->realize(); |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | public function findPostHeaders(?\DateTime $from = null): array |
76 | 76 | { |
77 | 77 | return self::$postHeaders |
78 | - ->filter(function ($header) use ($from) { |
|
78 | + ->filter(function($header) use ($from) { |
|
79 | 79 | return $from == null || $header->getCreatedAt() >= $from; |
80 | 80 | }) |
81 | - ->map(function ($header) { |
|
81 | + ->map(function($header) { |
|
82 | 82 | return new CommentsPostHeaderDto( |
83 | 83 | $header->getId(), |
84 | 84 | $header->getTitle(), |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | $id = new Ulid(); |
95 | 95 | $parentComment = null; |
96 | 96 | if ($newComment->getParentId() != null) { |
97 | - $parentComment = self::$comments->find(function ($comment) use ($newComment) { |
|
97 | + $parentComment = self::$comments->find(function($comment) use ($newComment) { |
|
98 | 98 | return $comment->getId() == $newComment->getParentId(); |
99 | 99 | }); |
100 | 100 | } |
101 | - $post = self::$postHeaders->find(function ($post) use ($newComment) { |
|
101 | + $post = self::$postHeaders->find(function($post) use ($newComment) { |
|
102 | 102 | return $post->getId() == $newComment->getPostId(); |
103 | 103 | }); |
104 | 104 | $comment = new InMemoryComment( |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | public function getCommentsCount(Ulid $postId): int |
120 | 120 | { |
121 | 121 | return self::$postHeaders |
122 | - ->filter(function ($post) use ($postId) { |
|
122 | + ->filter(function($post) use ($postId) { |
|
123 | 123 | return $post->getId() == $postId; |
124 | 124 | }) |
125 | - ->map(function ($post) { |
|
125 | + ->map(function($post) { |
|
126 | 126 | return count($post->getComments()); |
127 | 127 | }) |
128 | 128 | ->first(); |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | public function findCommentsByPostId(Ulid $postId): array |
132 | 132 | { |
133 | 133 | $post = self::$postHeaders |
134 | - ->find(function ($post) use ($postId) { |
|
134 | + ->find(function($post) use ($postId) { |
|
135 | 135 | return $post->getId() == $postId; |
136 | 136 | }); |
137 | 137 | if ($post == null) { |
138 | 138 | return []; |
139 | 139 | } |
140 | 140 | return Collection::from($post->getComments()) |
141 | - ->map(function ($comment) { |
|
141 | + ->map(function($comment) { |
|
142 | 142 | $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null; |
143 | 143 | return new CommentDto( |
144 | 144 | $comment->getId(), |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $from = ($pageNo - 1) * self::PAGE_SIZE; |
156 | 156 | $to = $from + self::PAGE_SIZE; |
157 | 157 | $data = self::$comments |
158 | - ->map(function ($comment) { |
|
158 | + ->map(function($comment) { |
|
159 | 159 | $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null; |
160 | 160 | return new CommentWithPostDto( |
161 | 161 | $comment->getId(), |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | ); |
171 | 171 | }) |
172 | - ->sort(function ($c1, $c2) { |
|
172 | + ->sort(function($c1, $c2) { |
|
173 | 173 | return $c1->getCreatedAt() < $c2->getCreatedAt() ? 1 : -1; |
174 | 174 | }) |
175 | 175 | ->slice($from, $to) |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | public function commentExists(Ulid $commentId): bool |
181 | 181 | { |
182 | 182 | return self::$comments |
183 | - ->filter(function ($comment) use ($commentId) { |
|
183 | + ->filter(function($comment) use ($commentId) { |
|
184 | 184 | return $comment->getId() == $commentId; |
185 | 185 | })->sizeIsGreaterThan(0); |
186 | 186 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | public function postExists(Ulid $postId): bool |
189 | 189 | { |
190 | 190 | return self::$postHeaders |
191 | - ->filter(function ($post) use ($postId) { |
|
191 | + ->filter(function($post) use ($postId) { |
|
192 | 192 | return $post->getId() == $postId; |
193 | 193 | })->sizeIsGreaterThan(0); |
194 | 194 | } |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | public function deleteCommentsForPost(Ulid $postId) |
197 | 197 | { |
198 | 198 | self::$comments = self::$comments |
199 | - ->filter(function ($comment) use ($postId) { |
|
199 | + ->filter(function($comment) use ($postId) { |
|
200 | 200 | return $comment->getPost()->getId() != $postId; |
201 | 201 | }) |
202 | 202 | ->realize(); |
203 | - $post = self::$postHeaders->find(function ($post) use ($postId) { |
|
203 | + $post = self::$postHeaders->find(function($post) use ($postId) { |
|
204 | 204 | $post->getId() == $postId; |
205 | 205 | }); |
206 | 206 | if ($post != null) { |