@@ -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 | } |
@@ -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 |
@@ -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 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | |
32 | 32 | protected function getContractsPath(): string |
33 | 33 | { |
34 | - return dirname(__FILE__) . '/../../../contracts'; |
|
34 | + return dirname(__FILE__).'/../../../contracts'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public static abstract function fail(string $message); |
@@ -19,7 +19,7 @@ |
||
19 | 19 | $dtoClass = CommentsPostHeaderDto::class; |
20 | 20 | $dql = "select new $dtoClass(p.id, p.title, p.tags, p.version) from $headerClass p"; |
21 | 21 | if ($from != null) { |
22 | - $dql = $dql . " where p.createdAt >= :from"; |
|
22 | + $dql = $dql." where p.createdAt >= :from"; |
|
23 | 23 | } |
24 | 24 | $query = $this->getEntityManager()->createQuery($dql); |
25 | 25 | if ($from != null) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if ($value == null) { |
103 | 103 | return null; |
104 | 104 | } |
105 | - return is_string($value) ? $value : (string)$value; |
|
105 | + return is_string($value) ? $value : (string) $value; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if ($nullable) { |
117 | 117 | return null; |
118 | 118 | } |
119 | - $name = call_user_func(get_called_class() . '::getName'); |
|
119 | + $name = call_user_func(get_called_class().'::getName'); |
|
120 | 120 | throw new RuntimeException("Event $name requires a field '$fieldName' to be present"); |
121 | 121 | } |
122 | 122 | return $this->data[$fieldName]; |