@@ -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,9 +126,9 @@ discard block |
||
126 | 126 | |
127 | 127 | public function findTags(): array |
128 | 128 | { |
129 | - return array_values(self::$tags->map(function ($tag) { |
|
129 | + return array_values(self::$tags->map(function($tag) { |
|
130 | 130 | return new TagDto($tag->getTag(), $this->countPosts($tag)); |
131 | - })->sort(function ($tag1, $tag2) { |
|
131 | + })->sort(function($tag1, $tag2) { |
|
132 | 132 | return $tag1->getPostsCount() > $tag2->getPostsCount(); |
133 | 133 | })->toArray()); |
134 | 134 | } |
@@ -138,23 +138,23 @@ discard block |
||
138 | 138 | $from = ($pageNo - 1) * self::PAGE_SIZE; |
139 | 139 | $to = $from + self::PAGE_SIZE; |
140 | 140 | $size = self::$postHeaders |
141 | - ->filter(function ($post) use ($tag) { |
|
141 | + ->filter(function($post) use ($tag) { |
|
142 | 142 | return Collection::from($post->getTags()) |
143 | - ->filter(function ($postTag) use ($tag) { |
|
143 | + ->filter(function($postTag) use ($tag) { |
|
144 | 144 | return $postTag->getTag() == $tag->getTag(); |
145 | 145 | }) |
146 | 146 | ->size() > 0; |
147 | 147 | })->size(); |
148 | 148 | $data = array_values(self::$postHeaders |
149 | - ->filter(function ($post) use ($tag) { |
|
149 | + ->filter(function($post) use ($tag) { |
|
150 | 150 | return Collection::from($post->getTags()) |
151 | - ->filter(function ($postTag) use ($tag) { |
|
151 | + ->filter(function($postTag) use ($tag) { |
|
152 | 152 | return $postTag->getTag() == $tag->getTag(); |
153 | 153 | }) |
154 | 154 | ->size() > 0; |
155 | 155 | }) |
156 | 156 | ->slice($from, $to) |
157 | - ->map(function ($header) { |
|
157 | + ->map(function($header) { |
|
158 | 158 | return new TagsPostHeaderDto( |
159 | 159 | $header->getId(), |
160 | 160 | $header->getTitle(), |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $header->getVersion(), |
166 | 166 | $header->getCommentsCount(), |
167 | 167 | Collection::from($header->getTags()) |
168 | - ->map(function ($tag) { |
|
168 | + ->map(function($tag) { |
|
169 | 169 | return $tag->getTag(); |
170 | 170 | }) |
171 | 171 | ->toArray() |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | private function countPosts(InMemoryTag $tag): int |
179 | 179 | { |
180 | 180 | return self::$postHeaders |
181 | - ->filter(function ($post) use ($tag) { |
|
181 | + ->filter(function($post) use ($tag) { |
|
182 | 182 | return Collection::from($post->getTags()) |
183 | - ->filter(function ($postTag) use ($tag) { |
|
183 | + ->filter(function($postTag) use ($tag) { |
|
184 | 184 | return $postTag->getTag() == $tag->getTag(); |
185 | 185 | }) |
186 | 186 | ->size() > 0; |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | public function updatePostTags(Ulid $postId, array $tags): void |
192 | 192 | { |
193 | 193 | self::$postHeaders |
194 | - ->filter(function ($post) use ($postId) { |
|
194 | + ->filter(function($post) use ($postId) { |
|
195 | 195 | return $post->getId() == $postId; |
196 | 196 | }) |
197 | - ->each(function ($post) { |
|
197 | + ->each(function($post) { |
|
198 | 198 | $post->setTags([]); |
199 | 199 | })->realize(); |
200 | 200 | foreach ($tags as $tag) { |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | |
205 | 205 | private function addPostToTag(string $tag, Ulid $postId): void |
206 | 206 | { |
207 | - $tagObj = self::$tags->find(function ($tagObj) use ($tag) { |
|
207 | + $tagObj = self::$tags->find(function($tagObj) use ($tag) { |
|
208 | 208 | return $tagObj->getTag() == $tag; |
209 | 209 | }); |
210 | 210 | if ($tagObj == null) { |
211 | 211 | $tagObj = new InMemoryTag(new Ulid(), $tag); |
212 | 212 | self::$tags = self::$tags->append($tagObj); |
213 | 213 | } |
214 | - $post = self::$postHeaders->find(function ($post) use ($postId) { |
|
214 | + $post = self::$postHeaders->find(function($post) use ($postId) { |
|
215 | 215 | return $post->getId() == $postId; |
216 | 216 | }); |
217 | 217 | if ($post != null) { |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | array_push($tags, $tagObj); |
220 | 220 | $post->setTags($tags); |
221 | 221 | } else { |
222 | - throw new \RuntimeException("No Post Header: " . $postId); |
|
222 | + throw new \RuntimeException("No Post Header: ".$postId); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | 226 | public function updatePostCommentsCount(UpdatePostsCommentsCountDto $commentsCount): void |
227 | 227 | { |
228 | 228 | self::$postHeaders |
229 | - ->filter(function ($header) use ($commentsCount) { |
|
229 | + ->filter(function($header) use ($commentsCount) { |
|
230 | 230 | return $header->getId() == $commentsCount->getPostId(); |
231 | 231 | }) |
232 | - ->each(function ($header) use ($commentsCount) { |
|
232 | + ->each(function($header) use ($commentsCount) { |
|
233 | 233 | $header->setCommentsCount($commentsCount->getCommentsCount()); |
234 | 234 | }) |
235 | 235 | ->realize(); |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | public function updateUserName(UpdatedTagsPostHeadersUserNameDto $updatedUserName): void |
239 | 239 | { |
240 | 240 | self::$postHeaders |
241 | - ->filter(function ($post) use ($updatedUserName) { |
|
241 | + ->filter(function($post) use ($updatedUserName) { |
|
242 | 242 | return $post->getCreatedByName() == $updatedUserName->getOldUserName(); |
243 | 243 | }) |
244 | - ->each(function ($post) use ($updatedUserName) { |
|
244 | + ->each(function($post) use ($updatedUserName) { |
|
245 | 245 | $post->setCreatedByName($updatedUserName->getNewUserName()); |
246 | 246 | }) |
247 | 247 | ->realize(); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function postExists(Ulid $postId): bool |
251 | 251 | { |
252 | 252 | return self::$postHeaders |
253 | - ->filter(function ($post) use ($postId) { |
|
253 | + ->filter(function($post) use ($postId) { |
|
254 | 254 | return $post->getId() == $postId; |
255 | 255 | })->sizeIsGreaterThan(0); |
256 | 256 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function onPostBaselined(PostBaselinedTagsIEvent $event): void |
36 | 36 | { |
37 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
38 | - if($this->postHeadersFindingRepository->postExists($event->getId())) { |
|
37 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
38 | + if ($this->postHeadersFindingRepository->postExists($event->getId())) { |
|
39 | 39 | $this->postEventsTagsRepository->updatePostHeader( |
40 | 40 | new UpdateExistingTagsPostHeaderDto( |
41 | 41 | $event->getId(), |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function onPostCreated(PostCreatedTagsIEvent $event): void |
73 | 73 | { |
74 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
74 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
75 | 75 | $this->postEventsTagsRepository->createPostHeader( |
76 | 76 | new CreateNewTagsPostHeaderDto( |
77 | 77 | $event->getId(), |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function onPostUpdated(PostUpdatedTagsIEvent $event): void |
96 | 96 | { |
97 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
97 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
98 | 98 | $this->postEventsTagsRepository->updatePostHeader( |
99 | 99 | new UpdateExistingTagsPostHeaderDto( |
100 | 100 | $event->getId(), |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function onPostDeleted(PostDeletedTagsIEvent $event): void |
116 | 116 | { |
117 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
117 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
118 | 118 | $this->postEventsTagsRepository->deletePostHeader( |
119 | 119 | new DeleteExistingTagsPostHeaderDto($event->getId()) |
120 | 120 | ); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function onPostBaselined(PostBaselinedCommentsIEvent $event): void |
37 | 37 | { |
38 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
38 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
39 | 39 | if ($this->postHeadersFindingRepository->postExists($event->getId())) { |
40 | 40 | $this->postEventsCommentsRepository->updatePostHeader( |
41 | 41 | new UpdateExistingCommentsPostHeaderDto( |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function onPostCreated(PostCreatedCommentsIEvent $event): void |
67 | 67 | { |
68 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
68 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
69 | 69 | $this->postEventsCommentsRepository->createPostHeader( |
70 | 70 | new CreateNewCommentsPostHeaderDto( |
71 | 71 | $event->getId(), |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function onPostUpdated(PostUpdatedCommentsIEvent $event): void |
84 | 84 | { |
85 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
85 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
86 | 86 | $this->postEventsCommentsRepository->updatePostHeader( |
87 | 87 | new UpdateExistingCommentsPostHeaderDto( |
88 | 88 | $event->getId(), |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function onPostDeleted(PostDeletedCommentsIEvent $event): void |
102 | 102 | { |
103 | - $this->transactionFactory->createTransaction(function () use ($event) { |
|
103 | + $this->transactionFactory->createTransaction(function() use ($event) { |
|
104 | 104 | $this->commentsDeletionRepository->deleteCommentsForPost($event->getId()); |
105 | 105 | $this->postEventsCommentsRepository->deletePostHeader( |
106 | 106 | new DeleteExistingCommentsPostHeaderDto($event->getId()) |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | p.id, p.title, p.body, p.summary, p.tags, p.createdById, p.createdByName, p.createdAt, p.updatedAt, p.version |
87 | 87 | ) from $postClass p where p.deletedAt is null"; |
88 | 88 | if ($from != null) { |
89 | - $dql = $dql . " and p.createdAt >= :from"; |
|
89 | + $dql = $dql." and p.createdAt >= :from"; |
|
90 | 90 | } |
91 | 91 | $query = $this->getEntityManager()->createQuery( |
92 | 92 | $dql |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $postClass = Post::class; |
107 | 107 | $dql = "select p.id as postId from $postClass p where p.deletedAt is not null"; |
108 | 108 | if ($from != null) { |
109 | - $dql = $dql . " and p.deletedAt >= :from"; |
|
109 | + $dql = $dql." and p.deletedAt >= :from"; |
|
110 | 110 | } |
111 | 111 | $query = $this->getEntityManager()->createQuery( |
112 | 112 | $dql |