@@ -62,10 +62,10 @@ |
||
62 | 62 | public function updatePostHeader(UpdateExistingTagsPostHeaderDto $updatedPostHeader): void |
63 | 63 | { |
64 | 64 | foreach (self::$postHeaders |
65 | - ->filter(function ($header) use ($updatedPostHeader) { |
|
66 | - return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion(); |
|
67 | - }) |
|
68 | - ->toArray() as $header) { |
|
65 | + ->filter(function ($header) use ($updatedPostHeader) { |
|
66 | + return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion(); |
|
67 | + }) |
|
68 | + ->toArray() as $header) { |
|
69 | 69 | $header->setTitle($updatedPostHeader->getTitle()); |
70 | 70 | $header->setSummary($updatedPostHeader->getSummary()); |
71 | 71 | $header->setVersion($updatedPostHeader->getVersion()); |
@@ -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(); |
@@ -111,7 +111,7 @@ |
||
111 | 111 | */ |
112 | 112 | public function getTagPosts(): Collection |
113 | 113 | { |
114 | - if($this->tagPosts === null) { |
|
114 | + if ($this->tagPosts === null) { |
|
115 | 115 | $this->tagPosts = new ArrayCollection(); |
116 | 116 | } |
117 | 117 | return $this->tagPosts; |
@@ -24,14 +24,14 @@ |
||
24 | 24 | * @param Ulid $postId |
25 | 25 | * @param array $tags |
26 | 26 | */ |
27 | - public function createUpdateTags(Ulid $postId, array $tags): void |
|
27 | + public function createUpdateTags(Ulid $postId, array $tags): void |
|
28 | 28 | { |
29 | 29 | $this->tagsUpdatingRepository->updatePostTags($postId, $tags); |
30 | 30 | $this->deleteEmptyTags(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | - public function deleteEmptyTags(): void |
|
34 | + public function deleteEmptyTags(): void |
|
35 | 35 | { |
36 | 36 | $this->tagsDeletingRepository->deleteEmptyTags(); |
37 | 37 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | parent::__construct($managerRegistry); |
18 | 18 | } |
19 | 19 | |
20 | - public function createTransaction($func): TransactionInterface |
|
20 | + public function createTransaction($func): TransactionInterface |
|
21 | 21 | { |
22 | 22 | $em = $this->managerRegistry->resetManager($this->getManagerName()); |
23 | 23 | return new DoctrineTransaction($em, $func); |