@@ -54,9 +54,9 @@ |
||
54 | 54 | { |
55 | 55 | return $this |
56 | 56 | ->subscribedHandlers |
57 | - ->filter(function ($value, $key) use ($event) { |
|
57 | + ->filter(function($value, $key) use ($event) { |
|
58 | 58 | return $key == $event->getName(); |
59 | - })->map(function ($value) { |
|
59 | + })->map(function($value) { |
|
60 | 60 | return $value; |
61 | 61 | })->toArray(); |
62 | 62 | } |
@@ -14,7 +14,7 @@ |
||
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 |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 | } |
@@ -62,7 +62,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -31,7 +31,7 @@ |
||
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 |
@@ -65,7 +65,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -26,25 +26,25 @@ |
||
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 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function updatePostHeader(UpdateExistingUserPostHeaderDto $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) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function deletePostHeader(DeleteExistingUserPostHeaderDto $deletedPostHeader): void |
77 | 77 | { |
78 | 78 | self::$postHeaders = self::$postHeaders->filter( |
79 | - function ($header) use ($deletedPostHeader) { |
|
79 | + function($header) use ($deletedPostHeader) { |
|
80 | 80 | return $header->getId() != $deletedPostHeader->getId(); |
81 | 81 | } |
82 | 82 | )->realize(); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function findPostHeaders(): array |
86 | 86 | { |
87 | 87 | return self::$postHeaders |
88 | - ->map(function ($header) { |
|
88 | + ->map(function($header) { |
|
89 | 89 | return new UserPostHeaderDto( |
90 | 90 | $header->getId(), |
91 | 91 | $header->getTitle(), |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $from = ($pageNo - 1) * self::PAGE_SIZE; |
114 | 114 | $to = $from + self::PAGE_SIZE; |
115 | 115 | $size = self::$postHeaders |
116 | - ->filter(function ($header) use ($userId) { |
|
116 | + ->filter(function($header) use ($userId) { |
|
117 | 117 | return $header->getUser()->getId() == $userId; |
118 | 118 | })->size(); |
119 | 119 | $data = self::$postHeaders |
120 | - ->filter(function ($header) use ($userId) { |
|
120 | + ->filter(function($header) use ($userId) { |
|
121 | 121 | return $header->getUser()->getId() == $userId; |
122 | 122 | }) |
123 | 123 | ->slice($from, $to) |
124 | - ->map(function ($header) { |
|
124 | + ->map(function($header) { |
|
125 | 125 | return new UserPostHeaderDto( |
126 | 126 | $header->getId(), |
127 | 127 | $header->getTitle(), |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | public function updatePostCommentsCount(UpdatePostsCommentsCountDto $commentsCount): void |
142 | 142 | { |
143 | 143 | self::$postHeaders |
144 | - ->filter(function ($header) use ($commentsCount) { |
|
144 | + ->filter(function($header) use ($commentsCount) { |
|
145 | 145 | return $header->getId() == $commentsCount->getPostId(); |
146 | 146 | }) |
147 | - ->each(function ($header) use ($commentsCount) { |
|
147 | + ->each(function($header) use ($commentsCount) { |
|
148 | 148 | $header->setCommentsCount($commentsCount->getCommentsCount()); |
149 | 149 | }) |
150 | 150 | ->realize(); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | public function exists(string $login): bool |
154 | 154 | { |
155 | 155 | return self::$users |
156 | - ->filter(function ($user) use ($login) { |
|
156 | + ->filter(function($user) use ($login) { |
|
157 | 157 | return $user->getEmail() == $login; |
158 | 158 | }) |
159 | 159 | ->sizeIsGreaterThan(0); |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | public function renameUser(RenameExistingUserDto $renamedUser): void |
163 | 163 | { |
164 | 164 | self::$users |
165 | - ->filter(function ($user) use ($renamedUser) { |
|
165 | + ->filter(function($user) use ($renamedUser) { |
|
166 | 166 | return $user->getEmail() == $renamedUser->getCurrentLogin(); |
167 | 167 | }) |
168 | - ->each(function ($user) use ($renamedUser) { |
|
168 | + ->each(function($user) use ($renamedUser) { |
|
169 | 169 | $user->setEmail($renamedUser->getNewLogin()); |
170 | 170 | }); |
171 | 171 | } |
@@ -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 |