@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | ) |
23 | 23 | { |
24 | 24 | $this->subscribedHandlers = Collection::from($this->subscribe()) |
25 | - ->map(function ($handlerMethodName, $eventClass) { |
|
25 | + ->map(function($handlerMethodName, $eventClass) { |
|
26 | 26 | return EventHandlerReference::create($handlerMethodName, $eventClass); |
27 | 27 | }) |
28 | 28 | ->realize(); |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | { |
59 | 59 | return $this |
60 | 60 | ->subscribedHandlers |
61 | - ->filter(function ($ref) use ($event) { |
|
61 | + ->filter(function($ref) use ($event) { |
|
62 | 62 | return $ref->getEventName() == $event->getName(); |
63 | - })->map(function ($value) { |
|
63 | + })->map(function($value) { |
|
64 | 64 | return $value; |
65 | 65 | })->toArray(); |
66 | 66 | } |
@@ -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 |
@@ -33,14 +33,14 @@ |
||
33 | 33 | $handler = $this->func; |
34 | 34 | $result = $handler(); |
35 | 35 | $this->afterCommit |
36 | - ->each(function ($successFn) use ($result) { |
|
36 | + ->each(function($successFn) use ($result) { |
|
37 | 37 | $successFn($result); |
38 | 38 | }) |
39 | 39 | ->realize(); |
40 | 40 | return $result; |
41 | 41 | } catch (\Exception $e) { |
42 | 42 | $this->afterRollback |
43 | - ->each(function ($rollbackFn) { |
|
43 | + ->each(function($rollbackFn) { |
|
44 | 44 | $rollbackFn(); |
45 | 45 | }) |
46 | 46 | ->realize(); |
@@ -38,7 +38,7 @@ |
||
38 | 38 | { |
39 | 39 | return array_values( |
40 | 40 | InMemoryEventPublisher::$publishedEvents |
41 | - ->filter(function ($event) use ($eventClass) { |
|
41 | + ->filter(function($event) use ($eventClass) { |
|
42 | 42 | return $event::class == $eventClass; |
43 | 43 | }) |
44 | 44 | ->toArray() |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void |
54 | 54 | { |
55 | 55 | 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 | - ->each(function ($header) use ($updatedPostHeader) { |
|
59 | + ->each(function($header) use ($updatedPostHeader) { |
|
60 | 60 | $header->setTitle($updatedPostHeader->getTitle()); |
61 | 61 | $header->setTags($updatedPostHeader->getTags()); |
62 | 62 | $header->setVersion($updatedPostHeader->getVersion()); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function deletePostHeader(DeleteExistingCommentsPostHeaderDto $deletedPostHeader): void |
68 | 68 | { |
69 | 69 | self::$postHeaders = self::$postHeaders->filter( |
70 | - function ($header) use ($deletedPostHeader) { |
|
70 | + function($header) use ($deletedPostHeader) { |
|
71 | 71 | return $header->getId() != $deletedPostHeader->getId(); |
72 | 72 | } |
73 | 73 | )->realize(); |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | public function findPostHeaders(?\DateTime $from = null): array |
77 | 77 | { |
78 | 78 | return self::$postHeaders |
79 | - ->filter(function ($header) use ($from) { |
|
79 | + ->filter(function($header) use ($from) { |
|
80 | 80 | return $from == null || $header->getCreatedAt() >= $from; |
81 | 81 | }) |
82 | - ->map(function ($header) { |
|
82 | + ->map(function($header) { |
|
83 | 83 | return new CommentsPostHeaderDto( |
84 | 84 | $header->getId(), |
85 | 85 | $header->getTitle(), |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | $id = new Ulid(); |
96 | 96 | $parentComment = null; |
97 | 97 | if ($newComment->getParentId() != null) { |
98 | - $parentComment = self::$comments->find(function ($comment) use ($newComment) { |
|
98 | + $parentComment = self::$comments->find(function($comment) use ($newComment) { |
|
99 | 99 | return $comment->getId() == $newComment->getParentId(); |
100 | 100 | }); |
101 | 101 | } |
102 | - $post = self::$postHeaders->find(function ($post) use ($newComment) { |
|
102 | + $post = self::$postHeaders->find(function($post) use ($newComment) { |
|
103 | 103 | return $post->getId() == $newComment->getPostId(); |
104 | 104 | }); |
105 | 105 | $comment = new InMemoryComment( |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | public function getCommentsCount(Ulid $postId): int |
121 | 121 | { |
122 | 122 | return self::$postHeaders |
123 | - ->filter(function ($post) use ($postId) { |
|
123 | + ->filter(function($post) use ($postId) { |
|
124 | 124 | return $post->getId() == $postId; |
125 | 125 | }) |
126 | - ->map(function ($post) { |
|
126 | + ->map(function($post) { |
|
127 | 127 | return count($post->getComments()); |
128 | 128 | }) |
129 | 129 | ->first(); |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | public function findCommentsByPostId(Ulid $postId): array |
133 | 133 | { |
134 | 134 | $post = self::$postHeaders |
135 | - ->find(function ($post) use ($postId) { |
|
135 | + ->find(function($post) use ($postId) { |
|
136 | 136 | return $post->getId() == $postId; |
137 | 137 | }); |
138 | 138 | if ($post == null) { |
139 | 139 | return []; |
140 | 140 | } |
141 | 141 | return Collection::from($post->getComments()) |
142 | - ->map(function ($comment) { |
|
142 | + ->map(function($comment) { |
|
143 | 143 | $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null; |
144 | 144 | return new CommentDto( |
145 | 145 | $comment->getId(), |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $from = ($pageNo - 1) * self::PAGE_SIZE; |
157 | 157 | $to = $from + self::PAGE_SIZE; |
158 | 158 | $data = self::$comments |
159 | - ->map(function ($comment) { |
|
159 | + ->map(function($comment) { |
|
160 | 160 | $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null; |
161 | 161 | return new CommentWithPostDto( |
162 | 162 | $comment->getId(), |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | ); |
172 | 172 | }) |
173 | - ->sort(function ($c1, $c2) { |
|
173 | + ->sort(function($c1, $c2) { |
|
174 | 174 | return $c1->getCreatedAt() < $c2->getCreatedAt() ? 1 : -1; |
175 | 175 | }) |
176 | 176 | ->slice($from, $to) |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | public function commentExists(Ulid $commentId): bool |
182 | 182 | { |
183 | 183 | return self::$comments |
184 | - ->filter(function ($comment) use ($commentId) { |
|
184 | + ->filter(function($comment) use ($commentId) { |
|
185 | 185 | return $comment->getId() == $commentId; |
186 | 186 | })->sizeIsGreaterThan(0); |
187 | 187 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | public function postExists(Ulid $postId): bool |
190 | 190 | { |
191 | 191 | return self::$postHeaders |
192 | - ->filter(function ($post) use ($postId) { |
|
192 | + ->filter(function($post) use ($postId) { |
|
193 | 193 | return $post->getId() == $postId; |
194 | 194 | })->sizeIsGreaterThan(0); |
195 | 195 | } |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | public function deleteCommentsForPost(Ulid $postId) |
198 | 198 | { |
199 | 199 | self::$comments = self::$comments |
200 | - ->filter(function ($comment) use ($postId) { |
|
200 | + ->filter(function($comment) use ($postId) { |
|
201 | 201 | return $comment->getPost()->getId() != $postId; |
202 | 202 | }) |
203 | 203 | ->realize(); |
204 | - $post = self::$postHeaders->find(function ($post) use ($postId) { |
|
204 | + $post = self::$postHeaders->find(function($post) use ($postId) { |
|
205 | 205 | $post->getId() == $postId; |
206 | 206 | }); |
207 | 207 | if ($post != null) { |
@@ -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,10 +75,10 @@ discard block |
||
75 | 75 | public function updatePost(UpdateExistingPostDto $dto): void |
76 | 76 | { |
77 | 77 | self::$posts |
78 | - ->filter(function ($post) use ($dto) { |
|
78 | + ->filter(function($post) use ($dto) { |
|
79 | 79 | return $post->getId() == $dto->getId(); |
80 | 80 | }) |
81 | - ->each(function ($post) use ($dto) { |
|
81 | + ->each(function($post) use ($dto) { |
|
82 | 82 | $post->setTitle($dto->getTitle()); |
83 | 83 | $post->setBody($dto->getBody()); |
84 | 84 | $post->setSummary($dto->getSummary()); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function findPost(Ulid $id): ?PostDto |
93 | 93 | { |
94 | - $found = self::$posts->find(function ($post) use ($id) { |
|
94 | + $found = self::$posts->find(function($post) use ($id) { |
|
95 | 95 | return $post->getId() == $id; |
96 | 96 | }); |
97 | 97 | return $found == null ? null : new PostDto( |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $to = $from + self::PAGE_SIZE; |
115 | 115 | $data = self::$posts |
116 | 116 | ->slice($from, $to) |
117 | - ->map(function ($item) { |
|
117 | + ->map(function($item) { |
|
118 | 118 | return new PostHeaderDto( |
119 | 119 | $item->getId(), |
120 | 120 | $item->getTitle(), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | public function updateAllComments(UpdatePostCommentsDto $updatedComments, bool $append = true): void |
134 | 134 | { |
135 | - $post = self::$posts->find(function ($post) use ($updatedComments) { |
|
135 | + $post = self::$posts->find(function($post) use ($updatedComments) { |
|
136 | 136 | return $post->getId() == $updatedComments->getPostId(); |
137 | 137 | }); |
138 | 138 | if ($post == null) { |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | public function updateUserName(UpdatedPostsUserNameDto $updatedUserName): void |
166 | 166 | { |
167 | 167 | self::$posts |
168 | - ->filter(function ($post) use ($updatedUserName) { |
|
168 | + ->filter(function($post) use ($updatedUserName) { |
|
169 | 169 | return $post->getCreatedByName() == $updatedUserName->getOldUserName(); |
170 | 170 | }) |
171 | - ->each(function ($post) use ($updatedUserName) { |
|
171 | + ->each(function($post) use ($updatedUserName) { |
|
172 | 172 | $post->setCreatedByName($updatedUserName->getNewUserName()); |
173 | 173 | }) |
174 | 174 | ->realize(); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | try { |
37 | 37 | $result = $this->entityManager->wrapInTransaction($this->func); |
38 | 38 | $this->afterCommit |
39 | - ->each(function ($successFn) use ($result) { |
|
39 | + ->each(function($successFn) use ($result) { |
|
40 | 40 | $successFn($result); |
41 | 41 | }) |
42 | 42 | ->realize(); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | return $result; |
45 | 45 | } catch (\Exception $e) { |
46 | 46 | $this->afterRollback |
47 | - ->each(function ($rollbackFn) { |
|
47 | + ->each(function($rollbackFn) { |
|
48 | 48 | $rollbackFn(); |
49 | 49 | }) |
50 | 50 | ->realize(); |