From 441fdc06b32df8840b0e96efc058eadb9156fb7a Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Tue, 28 Mar 2023 22:57:11 +0300 Subject: [PATCH] Ported all API DTO's (without serializer configuration). --- old/src/PointToolsBundle/DTO/Api/MetaPost.php | 56 ----------- .../PointToolsBundle => src}/DTO/Api/Auth.php | 32 ++---- .../DTO/Api/Comment.php | 56 +++-------- src/DTO/Api/MetaPost.php | 40 ++++++++ .../PointToolsBundle => src}/DTO/Api/Post.php | 76 ++++---------- .../DTO/Api/PostsPage.php | 35 ++----- .../PointToolsBundle => src}/DTO/Api/User.php | 98 ++++--------------- .../DTO/Api/ValidableInterface.php | 6 +- 8 files changed, 111 insertions(+), 288 deletions(-) delete mode 100644 old/src/PointToolsBundle/DTO/Api/MetaPost.php rename {old/src/PointToolsBundle => src}/DTO/Api/Auth.php (60%) rename {old/src/PointToolsBundle => src}/DTO/Api/Comment.php (66%) create mode 100644 src/DTO/Api/MetaPost.php rename {old/src/PointToolsBundle => src}/DTO/Api/Post.php (67%) rename {old/src/PointToolsBundle => src}/DTO/Api/PostsPage.php (50%) rename {old/src/PointToolsBundle => src}/DTO/Api/User.php (70%) rename {old/src/PointToolsBundle => src}/DTO/Api/ValidableInterface.php (59%) diff --git a/old/src/PointToolsBundle/DTO/Api/MetaPost.php b/old/src/PointToolsBundle/DTO/Api/MetaPost.php deleted file mode 100644 index 3e240fc..0000000 --- a/old/src/PointToolsBundle/DTO/Api/MetaPost.php +++ /dev/null @@ -1,56 +0,0 @@ -post; - } - - public function setPost(?Post $post): void - { - $this->post = $post; - } - - /** - * @return Comment[]|null - */ - public function getComments(): ?array - { - return $this->comments; - } - - /** - * @param Comment[]|null $comments - */ - public function setComments(?array $comments): void - { - $this->comments = $comments; - } - - public function isValid(): bool - { - if (null !== $this->post && $this->post->isValid()) { - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/old/src/PointToolsBundle/DTO/Api/Auth.php b/src/DTO/Api/Auth.php similarity index 60% rename from old/src/PointToolsBundle/DTO/Api/Auth.php rename to src/DTO/Api/Auth.php index 17d9e2e..9eca83e 100644 --- a/old/src/PointToolsBundle/DTO/Api/Auth.php +++ b/src/DTO/Api/Auth.php @@ -1,26 +1,14 @@ token && null !== $this->csRfToken && null === $this->error) { - return true; - } - - return false; + return null !== $this->token && null !== $this->csRfToken && null === $this->error; } -} \ No newline at end of file +} diff --git a/old/src/PointToolsBundle/DTO/Api/Comment.php b/src/DTO/Api/Comment.php similarity index 66% rename from old/src/PointToolsBundle/DTO/Api/Comment.php rename to src/DTO/Api/Comment.php index 34884a7..550aeb2 100644 --- a/old/src/PointToolsBundle/DTO/Api/Comment.php +++ b/src/DTO/Api/Comment.php @@ -1,46 +1,18 @@ postId && null !== $this->number && null !== $this->author && null !== $this->text) { - return true; - } - - return false; + return null !== $this->postId && null !== $this->number && null !== $this->author && null !== $this->text; } -} \ No newline at end of file +} diff --git a/src/DTO/Api/MetaPost.php b/src/DTO/Api/MetaPost.php new file mode 100644 index 0000000..9e31a1b --- /dev/null +++ b/src/DTO/Api/MetaPost.php @@ -0,0 +1,40 @@ +post; + } + + public function setPost(?Post $post): void + { + $this->post = $post; + } + + /** @return Comment[]|null */ + public function getComments(): ?array + { + return $this->comments; + } + + /** @param Comment[]|null $comments */ + public function setComments(?array $comments): void + { + $this->comments = $comments; + } + + public function isValid(): bool + { + return null !== $this->post && $this->post->isValid(); + } +} diff --git a/old/src/PointToolsBundle/DTO/Api/Post.php b/src/DTO/Api/Post.php similarity index 67% rename from old/src/PointToolsBundle/DTO/Api/Post.php rename to src/DTO/Api/Post.php index e8d1819..7cdea5a 100644 --- a/old/src/PointToolsBundle/DTO/Api/Post.php +++ b/src/DTO/Api/Post.php @@ -1,52 +1,21 @@ id = $id; } - /** - * @return string[]|null - */ + /** @return string[]|null */ public function getTags(): ?array { return $this->tags; @@ -71,9 +38,7 @@ class Post implements ValidableInterface $this->tags = $tags; } - /** - * @return string[]|null - */ + /** @return string[]|null */ public function getFiles(): ?array { return $this->files; @@ -144,18 +109,13 @@ class Post implements ValidableInterface public function isValid(): bool { - if ( - null !== $this->id && + return null !== $this->id && null !== $this->author && $this->author->isValid() && null !== $this->text && - null !== $this->created// && + null !== $this->created // @todo check type existence in incoming data //null !== $this->type - ) { - return true; - } - - return false; + ; } } \ No newline at end of file diff --git a/old/src/PointToolsBundle/DTO/Api/PostsPage.php b/src/DTO/Api/PostsPage.php similarity index 50% rename from old/src/PointToolsBundle/DTO/Api/PostsPage.php rename to src/DTO/Api/PostsPage.php index 782669f..d0e4fa1 100644 --- a/old/src/PointToolsBundle/DTO/Api/PostsPage.php +++ b/src/DTO/Api/PostsPage.php @@ -1,33 +1,22 @@ posts; } - /** - * @param MetaPost[]|null $posts - */ + /** @param MetaPost[]|null $posts */ public function setPosts(?array $posts): void { $this->posts = $posts; @@ -45,10 +34,6 @@ class PostsPage implements ValidableInterface public function isValid(): bool { - if (null !== $this->posts) { - return true; - } - - return false; + return null !== $this->posts; } -} \ No newline at end of file +} diff --git a/old/src/PointToolsBundle/DTO/Api/User.php b/src/DTO/Api/User.php similarity index 70% rename from old/src/PointToolsBundle/DTO/Api/User.php rename to src/DTO/Api/User.php index 76657f8..345ccda 100644 --- a/old/src/PointToolsBundle/DTO/Api/User.php +++ b/src/DTO/Api/User.php @@ -1,81 +1,25 @@ error && null !== $this->id && null !== $this->login) { - return true; - } - - return false; + return null === $this->error && null !== $this->id && null !== $this->login; } -} \ No newline at end of file +} diff --git a/old/src/PointToolsBundle/DTO/Api/ValidableInterface.php b/src/DTO/Api/ValidableInterface.php similarity index 59% rename from old/src/PointToolsBundle/DTO/Api/ValidableInterface.php rename to src/DTO/Api/ValidableInterface.php index 20cd4ce..b7050cd 100644 --- a/old/src/PointToolsBundle/DTO/Api/ValidableInterface.php +++ b/src/DTO/Api/ValidableInterface.php @@ -1,7 +1,9 @@