-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
356c691
commit 5790ae0
Showing
34 changed files
with
714 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Collection; | ||
|
||
use App\Collection\CollectionInterface; | ||
|
||
interface CollectionRequestInterface | ||
{ | ||
public function createCollection(): CollectionInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Collection; | ||
|
||
use App\Collection\CollectionInterface; | ||
use App\Collection\PetCollection; | ||
|
||
final class PetCollectionRequest implements CollectionRequestInterface | ||
{ | ||
public int $offset; | ||
|
||
public int $limit; | ||
|
||
/** | ||
* @var array<string, string> | ||
*/ | ||
public array $filters; | ||
|
||
/** | ||
* @var array<string, string> | ||
*/ | ||
public array $sort; | ||
|
||
public function createCollection(): CollectionInterface | ||
{ | ||
$collection = new PetCollection(); | ||
$collection->setOffset($this->offset); | ||
$collection->setLimit($this->limit); | ||
$collection->setFilters($this->filters); | ||
$collection->setSort($this->sort); | ||
|
||
return $collection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Collection; | ||
|
||
use App\Dto\Model\PetResponse; | ||
|
||
final class PetCollectionResponse | ||
{ | ||
public int $offset; | ||
|
||
public int $limit; | ||
|
||
/** | ||
* @var array<string, string> | ||
*/ | ||
public array $filters; | ||
|
||
/** | ||
* @var array<string, string> | ||
*/ | ||
public array $sort; | ||
|
||
/** | ||
* @var array<PetResponse> | ||
*/ | ||
public array $items; | ||
|
||
public int $count; | ||
|
||
/** | ||
* @var array<string, LinkResponse> | ||
*/ | ||
public array $_links; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto; | ||
|
||
final class LinkResponse | ||
{ | ||
public string $href; | ||
|
||
/** | ||
* @var array<string, string> | ||
*/ | ||
public array $attributes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Model; | ||
|
||
use App\Model\ModelInterface; | ||
|
||
interface ModelRequestInterface | ||
{ | ||
public function createModel(): ModelInterface; | ||
|
||
public function updateModel(ModelInterface $model): ModelInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Model; | ||
|
||
use App\Model\ModelInterface; | ||
use App\Model\Pet; | ||
use App\Model\Vaccination; | ||
|
||
final class PetRequest implements ModelRequestInterface | ||
{ | ||
public string $name; | ||
|
||
public null|string $tag; | ||
|
||
/** | ||
* @var array<VaccinationRequest> | ||
*/ | ||
public array $vaccinations; | ||
|
||
public function createModel(): ModelInterface | ||
{ | ||
$vaccinations = []; | ||
foreach ($this->vaccinations as $vaccinationRequest) { | ||
$vaccination = new Vaccination(); | ||
$vaccination->setName($vaccinationRequest->name); | ||
|
||
$vaccinations[] = $vaccination; | ||
} | ||
|
||
$model = new Pet(); | ||
$model->setName($this->name); | ||
$model->setTag($this->tag); | ||
$model->setVaccinations($vaccinations); | ||
|
||
return $model; | ||
} | ||
|
||
/** | ||
* @param Pet $model | ||
*/ | ||
public function updateModel(ModelInterface $model): ModelInterface | ||
{ | ||
$vaccinations = []; | ||
foreach ($this->vaccinations as $vaccinationRequest) { | ||
$vaccination = new Vaccination(); | ||
$vaccination->setName($vaccinationRequest->name); | ||
|
||
$vaccinations[] = $vaccination; | ||
} | ||
|
||
$model->setName($this->name); | ||
$model->setTag($this->tag); | ||
$model->setVaccinations($vaccinations); | ||
|
||
return $model; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Model; | ||
|
||
use App\Dto\LinkResponse; | ||
|
||
final class PetResponse | ||
{ | ||
public string $id; | ||
|
||
public string $createdAt; | ||
|
||
public null|string $updatedAt; | ||
|
||
public string $name; | ||
|
||
public null|string $tag; | ||
|
||
/** | ||
* @var array<VaccinationResponse> | ||
*/ | ||
public array $vaccinations; | ||
|
||
/** | ||
* @var array<string, LinkResponse> | ||
*/ | ||
public array $_links; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Model; | ||
|
||
final class VaccinationRequest | ||
{ | ||
public string $name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Dto\Model; | ||
|
||
final class VaccinationResponse | ||
{ | ||
public string $name; | ||
} |
Oops, something went wrong.