@@ -20,7 +20,7 @@ |
||
20 | 20 | public function findPostsByUserId(FindPostsByUserIdQuery $query): Page |
21 | 21 | { |
22 | 22 | $client = $this->getClient(); |
23 | - $client->request('GET', '/api/security/' . $query->getUserId()); |
|
23 | + $client->request('GET', '/api/security/'.$query->getUserId()); |
|
24 | 24 | return $this->responseObject($client, Page::class); |
25 | 25 | } |
26 | 26 |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void |
61 | 61 | { |
62 | 62 | foreach (self::$postHeaders |
63 | - ->filter(function ($header) use ($updatedPostHeader) { |
|
64 | - return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion(); |
|
65 | - }) |
|
66 | - ->toArray() as $header) { |
|
63 | + ->filter(function ($header) use ($updatedPostHeader) { |
|
64 | + return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion(); |
|
65 | + }) |
|
66 | + ->toArray() as $header) { |
|
67 | 67 | $header->setTitle($updatedPostHeader->getTitle()); |
68 | 68 | $header->setSummary($updatedPostHeader->getSummary()); |
69 | 69 | $header->setTags($updatedPostHeader->getTags()); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function deletePostHeader(DeleteExistingCommentsPostHeaderDto $deletedPostHeader): void |
75 | 75 | { |
76 | 76 | self::$postHeaders = self::$postHeaders->filter( |
77 | - function ($header) use ($deletedPostHeader) { |
|
77 | + function ($header) use ($deletedPostHeader) { |
|
78 | 78 | return $header->getId() != $deletedPostHeader->getId(); |
79 | 79 | } |
80 | 80 | )->realize(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void |
61 | 61 | { |
62 | 62 | foreach (self::$postHeaders |
63 | - ->filter(function ($header) use ($updatedPostHeader) { |
|
63 | + ->filter(function($header) use ($updatedPostHeader) { |
|
64 | 64 | return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion(); |
65 | 65 | }) |
66 | 66 | ->toArray() as $header) { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function deletePostHeader(DeleteExistingCommentsPostHeaderDto $deletedPostHeader): void |
75 | 75 | { |
76 | 76 | self::$postHeaders = self::$postHeaders->filter( |
77 | - function ($header) use ($deletedPostHeader) { |
|
77 | + function($header) use ($deletedPostHeader) { |
|
78 | 78 | return $header->getId() != $deletedPostHeader->getId(); |
79 | 79 | } |
80 | 80 | )->realize(); |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | public function findPostHeaders(?\DateTime $from = null): array |
84 | 84 | { |
85 | 85 | return self::$postHeaders |
86 | - ->filter(function ($header) use ($from) { |
|
86 | + ->filter(function($header) use ($from) { |
|
87 | 87 | return $from == null || $header->getCreatedAt() >= $from; |
88 | 88 | }) |
89 | - ->map(function ($header) { |
|
89 | + ->map(function($header) { |
|
90 | 90 | return new CommentsPostHeaderDto( |
91 | 91 | $header->getId(), |
92 | 92 | $header->getTitle(), |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $id = new Ulid(); |
107 | 107 | $parentComment = null; |
108 | 108 | if ($newComment->getParentId() != null) { |
109 | - $parentComment = self::$comments->find(function ($comment) use ($newComment) { |
|
109 | + $parentComment = self::$comments->find(function($comment) use ($newComment) { |
|
110 | 110 | return $comment->getId() == $newComment->getParentId(); |
111 | 111 | }); |
112 | 112 | } |
113 | - $post = self::$postHeaders->find(function ($post) use ($newComment) { |
|
113 | + $post = self::$postHeaders->find(function($post) use ($newComment) { |
|
114 | 114 | return $post->getId() == $newComment->getPostId(); |
115 | 115 | }); |
116 | 116 | $comment = new InMemoryComment( |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | public function getCommentsCount(Ulid $postId): int |
132 | 132 | { |
133 | 133 | return self::$postHeaders |
134 | - ->filter(function ($post) use ($postId) { |
|
134 | + ->filter(function($post) use ($postId) { |
|
135 | 135 | return $post->getId() == $postId; |
136 | 136 | }) |
137 | - ->map(function ($post) { |
|
137 | + ->map(function($post) { |
|
138 | 138 | return count($post->getComments()); |
139 | 139 | }) |
140 | 140 | ->first(); |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | public function findCommentsByPostId(Ulid $postId): array |
144 | 144 | { |
145 | 145 | $post = self::$postHeaders |
146 | - ->find(function ($post) use ($postId) { |
|
146 | + ->find(function($post) use ($postId) { |
|
147 | 147 | return $post->getId() == $postId; |
148 | 148 | }); |
149 | 149 | if ($post == null) { |
150 | 150 | return []; |
151 | 151 | } |
152 | 152 | return Collection::from($post->getComments()) |
153 | - ->map(function ($comment) { |
|
153 | + ->map(function($comment) { |
|
154 | 154 | $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null; |
155 | 155 | return new CommentDto( |
156 | 156 | $comment->getId(), |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $from = ($pageNo - 1) * self::PAGE_SIZE; |
168 | 168 | $to = $from + self::PAGE_SIZE; |
169 | 169 | $data = self::$comments |
170 | - ->map(function ($comment) { |
|
170 | + ->map(function($comment) { |
|
171 | 171 | $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null; |
172 | 172 | return new CommentWithPostDto( |
173 | 173 | $comment->getId(), |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | $comment->getPost()->getTitle(), |
180 | 180 | $comment->getPost()->getSummary(), |
181 | 181 | self::$postHeaders |
182 | - ->filter(function ($post) use ($comment) { |
|
182 | + ->filter(function($post) use ($comment) { |
|
183 | 183 | return $post->getId() == $comment->getPost()->getId(); |
184 | 184 | })->size(), |
185 | 185 | $comment->getPost()->getTags(), |
186 | 186 | |
187 | 187 | ); |
188 | 188 | }) |
189 | - ->sort(function ($c1, $c2) { |
|
189 | + ->sort(function($c1, $c2) { |
|
190 | 190 | return $c1->getCreatedAt() < $c2->getCreatedAt() ? 1 : -1; |
191 | 191 | }) |
192 | 192 | ->slice($from, $to) |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | public function commentExists(Ulid $commentId): bool |
198 | 198 | { |
199 | 199 | return self::$comments |
200 | - ->filter(function ($comment) use ($commentId) { |
|
200 | + ->filter(function($comment) use ($commentId) { |
|
201 | 201 | return $comment->getId() == $commentId; |
202 | 202 | })->sizeIsGreaterThan(0); |
203 | 203 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | public function postExists(Ulid $postId): bool |
206 | 206 | { |
207 | 207 | return self::$postHeaders |
208 | - ->filter(function ($post) use ($postId) { |
|
208 | + ->filter(function($post) use ($postId) { |
|
209 | 209 | return $post->getId() == $postId; |
210 | 210 | })->sizeIsGreaterThan(0); |
211 | 211 | } |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | public function deleteCommentsForPost(Ulid $postId) |
214 | 214 | { |
215 | 215 | self::$comments = self::$comments |
216 | - ->filter(function ($comment) use ($postId) { |
|
216 | + ->filter(function($comment) use ($postId) { |
|
217 | 217 | return $comment->getPost()->getId() != $postId; |
218 | 218 | }) |
219 | 219 | ->realize(); |
220 | - $post = self::$postHeaders->find(function ($post) use ($postId) { |
|
220 | + $post = self::$postHeaders->find(function($post) use ($postId) { |
|
221 | 221 | $post->getId() == $postId; |
222 | 222 | }); |
223 | 223 | if ($post != null) { |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | public function updateUserName(UpdatedCommentsPostHeadersUserNameDto $updatedUserName): void |
230 | 230 | { |
231 | 231 | self::$postHeaders |
232 | - ->filter(function ($post) use ($updatedUserName) { |
|
232 | + ->filter(function($post) use ($updatedUserName) { |
|
233 | 233 | return $post->getCreatedByName() == $updatedUserName->getOldUserName(); |
234 | 234 | }) |
235 | - ->each(function ($post) use ($updatedUserName) { |
|
235 | + ->each(function($post) use ($updatedUserName) { |
|
236 | 236 | $post->setCreatedByName($updatedUserName->getNewUserName()); |
237 | 237 | }) |
238 | 238 | ->realize(); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function findLatestComments(FindLatestCommentsQuery $query): Page |
30 | 30 | { |
31 | 31 | $client = $this->getClient(); |
32 | - $client->request('GET', '/api/comments/?pageNo=' . $query->getPageNo()); |
|
32 | + $client->request('GET', '/api/comments/?pageNo='.$query->getPageNo()); |
|
33 | 33 | return $this->responseObject($client, Page::class); |
34 | 34 | } |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public function findCommentsForPost(FindCommentsByPostIdQuery $query): array |
41 | 41 | { |
42 | 42 | $client = $this->getClient(); |
43 | - $client->request('GET', '/api/comments/' . $query->getPostId()); |
|
43 | + $client->request('GET', '/api/comments/'.$query->getPostId()); |
|
44 | 44 | return $this->responseObjects($client, FindCommentsByPostIdQueryResponse::class); |
45 | 45 | } |
46 | 46 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | class InMemoryTransactionFactory implements TransactionFactoryInterface |
9 | 9 | { |
10 | 10 | |
11 | - public function createTransaction($func): TransactionInterface |
|
11 | + public function createTransaction($func): TransactionInterface |
|
12 | 12 | { |
13 | 13 | return new InMemoryTransaction($func); |
14 | 14 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @return mixed |
27 | 27 | * @throws \Exception |
28 | 28 | */ |
29 | - public function execute(): mixed |
|
29 | + public function execute(): mixed |
|
30 | 30 | { |
31 | 31 | try { |
32 | 32 | $handler = $this->func; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param $func |
49 | 49 | * @return $this |
50 | 50 | */ |
51 | - public function afterCommit($func): TransactionInterface |
|
51 | + public function afterCommit($func): TransactionInterface |
|
52 | 52 | { |
53 | 53 | $this->afterCommit->add($func); |
54 | 54 | return $this; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param $func |
59 | 59 | * @return $this |
60 | 60 | */ |
61 | - public function afterRollback($func): TransactionInterface |
|
61 | + public function afterRollback($func): TransactionInterface |
|
62 | 62 | { |
63 | 63 | $this->afterRollback->add($func); |
64 | 64 | return $this; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | - public function getUser(): LoggedInUser |
|
23 | + public function getUser(): LoggedInUser |
|
24 | 24 | { |
25 | 25 | return new LoggedInUser( |
26 | 26 | InMemoryLoggedInUserProvider::$USER_ID, |