Passed
Push — main ( 3025dd...ee4c89 )
by Slawomir
04:40
created
src/Modules/Posts/Api/PostsApiInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,39 +21,39 @@
 block discarded – undo
21 21
      * @param CreatePostCommand $command
22 22
      * @return CreatePostCommandResponse
23 23
      */
24
-   public function createPost(CreatePostCommand $command): CreatePostCommandResponse;
24
+    public function createPost(CreatePostCommand $command): CreatePostCommandResponse;
25 25
 
26 26
     /**
27 27
      * @param UpdatePostCommand $command
28 28
      */
29
-   public function updatePost(UpdatePostCommand $command): void;
29
+    public function updatePost(UpdatePostCommand $command): void;
30 30
 
31 31
     /**
32 32
      * @param DeletePostCommand $command
33 33
      */
34
-   public function deletePost(DeletePostCommand $command): void;
34
+    public function deletePost(DeletePostCommand $command): void;
35 35
 
36 36
     /**
37 37
      * @param FindAllPostsQuery $query
38 38
      * @return Page<FindPostQueryResponse>
39 39
      */
40
-   public function findAllPosts(FindAllPostsQuery $query): Page;
40
+    public function findAllPosts(FindAllPostsQuery $query): Page;
41 41
 
42 42
     /**
43 43
      * @param FindPostByIdQuery $query
44 44
      * @return FindPostQueryResponse|null
45 45
      */
46
-   public function findPostById(FindPostByIdQuery $query): ?FindPostQueryResponse;
46
+    public function findPostById(FindPostByIdQuery $query): ?FindPostQueryResponse;
47 47
 
48 48
     /**
49 49
      * @param CommentCreatedPostsIEvent $event
50 50
      */
51
-   public function onCommentCreated(CommentCreatedPostsIEvent $event): void;
51
+    public function onCommentCreated(CommentCreatedPostsIEvent $event): void;
52 52
 
53 53
     /**
54 54
      * @param CommentsBaselinedPostsIEvent $event
55 55
      */
56
-   public function onCommentsBaselined(CommentsBaselinedPostsIEvent $event): void;
56
+    public function onCommentsBaselined(CommentsBaselinedPostsIEvent $event): void;
57 57
 
58 58
     /**
59 59
      * @param BaselinePostsCommand $command
Please login to merge, or discard this patch.
src/Infrastructure/Transactions/TransactionInterface.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
  */
9 9
 interface TransactionInterface
10 10
 {
11
-   public function afterCommit($func): self;
11
+    public function afterCommit($func): self;
12 12
 
13
-   public function afterRollback($func): self;
13
+    public function afterRollback($func): self;
14 14
 
15
-   public function execute(): mixed;
15
+    public function execute(): mixed;
16 16
 }
17 17
\ No newline at end of file
Please login to merge, or discard this patch.
src/Infrastructure/Transactions/TransactionFactoryInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
      * @param $func
13 13
      * @return TransactionInterface
14 14
      */
15
-   public function createTransaction($func): TransactionInterface;
15
+    public function createTransaction($func): TransactionInterface;
16 16
 
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
src/Infrastructure/Doctrine/Transactions/DoctrineTransaction.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @return mixed
29 29
      * @throws \Exception
30 30
      */
31
-   public function execute(): mixed
31
+    public function execute(): mixed
32 32
     {
33 33
         try {
34 34
             $result = $this->entityManager->wrapInTransaction($this->func);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param $func
49 49
      * @return $this
50 50
      */
51
-   public function afterCommit($func): self
51
+    public function afterCommit($func): self
52 52
     {
53 53
         $this->afterCommit->add($func);
54 54
         return $this;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @param $func
59 59
      * @return $this
60 60
      */
61
-   public function afterRollback($func): self
61
+    public function afterRollback($func): self
62 62
     {
63 63
         $this->afterRollback->add($func);
64 64
         return $this;
Please login to merge, or discard this patch.
src/Infrastructure/Security/LoggedInUserProviderInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,5 +4,5 @@
 block discarded – undo
4 4
 
5 5
 interface LoggedInUserProviderInterface
6 6
 {
7
-   public function getUser(): LoggedInUser;
7
+    public function getUser(): LoggedInUser;
8 8
 }
9 9
\ No newline at end of file
Please login to merge, or discard this patch.
src/Infrastructure/Utils/StringUtil.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Modules/Comments/Domain/Logic/CommentsValidator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
tests/Modules/Tags/Unit/Repository/InMemoryTagsRepository.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         self::$tags = Collection::from([]);
46 46
     }
47 47
 
48
-   public function createPostHeader(CreateNewTagsPostHeaderDto $newPostHeader): void
48
+    public function createPostHeader(CreateNewTagsPostHeaderDto $newPostHeader): void
49 49
     {
50 50
         self::$postHeaders = self::$postHeaders->append(new InMemoryTagPostHeader(
51 51
             $newPostHeader->getId(),
@@ -59,29 +59,29 @@  discard block
 block discarded – undo
59 59
         ));
60 60
     }
61 61
 
62
-   public function updatePostHeader(UpdateExistingTagsPostHeaderDto $updatedPostHeader): void
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());
72 72
         }
73 73
     }
74 74
 
75
-   public function deletePostHeader(DeleteExistingTagsPostHeaderDto $deletedPostHeader): void
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();
82 82
     }
83 83
 
84
-   public function findPostHeaders(): array
84
+    public function findPostHeaders(): array
85 85
     {
86 86
         return self::$postHeaders
87 87
             ->map(function ($header) {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
tests/Modules/Tags/Integration/Http/TagsHttpTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.