refactor(mapper): rename hydrators to mappers across source, repositories and factory
This commit is contained in:
parent
55caa0729b
commit
1c0ecb2bd5
11 changed files with 143 additions and 109 deletions
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Factory;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\BrandHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\EmployeeHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoCompoHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoShortHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiConfig;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\BrandMapper;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\EmployeeMapper;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\IncoCompoMapper;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\IncoMapper;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\IncoShortMapper;
|
||||
use Uwil\ArcadiaApiPhpClient\Repository\BrandApiRepository;
|
||||
use Uwil\ArcadiaApiPhpClient\Repository\EmployeeApiRepository;
|
||||
use Uwil\ArcadiaApiPhpClient\Repository\IncoApiRepository;
|
||||
|
|
@ -56,7 +56,7 @@ final class ServiceFactory
|
|||
return $this->employeeService ??= new ArcadiaEmployeeService(
|
||||
new EmployeeApiRepository(
|
||||
$this->apiClient,
|
||||
new EmployeeHydrator()
|
||||
new EmployeeMapper()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -66,15 +66,15 @@ final class ServiceFactory
|
|||
return $this->incoService ??= new ArcadiaIncoService(
|
||||
new IncoApiRepository(
|
||||
$this->apiClient,
|
||||
new IncoHydrator()
|
||||
new IncoMapper()
|
||||
),
|
||||
new IncoShortApiRepository(
|
||||
$this->apiClient,
|
||||
new IncoShortHydrator()
|
||||
new IncoShortMapper()
|
||||
),
|
||||
new IncoCompoApiRepository(
|
||||
$this->apiClient,
|
||||
new IncoCompoHydrator()
|
||||
new IncoCompoMapper()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ final class ServiceFactory
|
|||
return $this->brandService ??= new ArcadiaBrandService(
|
||||
new BrandApiRepository(
|
||||
$this->apiClient,
|
||||
new BrandHydrator()
|
||||
new BrandMapper()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Hydrator;
|
||||
namespace Uwil\ArcadiaApiPhpClient\Mapper;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Brand;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
|
|
@ -16,7 +16,7 @@ use Uwil\ArcadiaKiotaOpenApiClient\Models\PaginationMeta;
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class BrandHydrator
|
||||
final class BrandMapper
|
||||
{
|
||||
public function toDto(KiotaBrand $model): Brand
|
||||
{
|
||||
|
|
@ -42,10 +42,18 @@ final class BrandHydrator
|
|||
$items[] = $this->toDto($brand);
|
||||
}
|
||||
|
||||
return new PageOf($this->hydratePagination($response->getPagination(), $pagination), $items);
|
||||
$paginationDto = $this->paginationDto(
|
||||
$response->getPagination(),
|
||||
$pagination
|
||||
);
|
||||
|
||||
return new PageOf(
|
||||
$paginationDto,
|
||||
$items
|
||||
);
|
||||
}
|
||||
|
||||
private function hydratePagination(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
private function paginationDto(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
{
|
||||
return new PaginationDto(
|
||||
page: $meta?->getPage() ?? $pagination->pageNumber(),
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Hydrator;
|
||||
namespace Uwil\ArcadiaApiPhpClient\Mapper;
|
||||
|
||||
use Microsoft\Kiota\Abstractions\Types\Date;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Employee;
|
||||
|
|
@ -20,7 +20,7 @@ use Uwil\ArcadiaKiotaOpenApiClient\Models\PaginationMeta;
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class EmployeeHydrator
|
||||
final class EmployeeMapper
|
||||
{
|
||||
public function toDto(KiotaEmployee $model): Employee
|
||||
{
|
||||
|
|
@ -57,10 +57,18 @@ final class EmployeeHydrator
|
|||
$items[] = $this->toDto($employeeModel);
|
||||
}
|
||||
|
||||
return new PageOf($this->hydratePagination($response->getPagination(), $pagination), $items);
|
||||
$paginationDto = $this->paginationDto(
|
||||
$response->getPagination(),
|
||||
$pagination
|
||||
);
|
||||
|
||||
return new PageOf(
|
||||
$paginationDto,
|
||||
$items
|
||||
);
|
||||
}
|
||||
|
||||
private function hydratePagination(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
private function paginationDto(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
{
|
||||
return new PaginationDto(
|
||||
page: $meta?->getPage() ?? $pagination->pageNumber(),
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Hydrator;
|
||||
namespace Uwil\ArcadiaApiPhpClient\Mapper;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoCompo;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoCompo\AcideGras;
|
||||
|
|
@ -28,7 +28,7 @@ use Uwil\ArcadiaKiotaOpenApiClient\Models\IncoCompo as KiotaIncoCompo;
|
|||
*
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
|
||||
*/
|
||||
final class IncoCompoHydrator
|
||||
final class IncoCompoMapper
|
||||
{
|
||||
public function toDto(KiotaIncoCompo $model): IncoCompo
|
||||
{
|
||||
|
|
@ -38,24 +38,24 @@ final class IncoCompoHydrator
|
|||
return new IncoCompo(
|
||||
id: $id,
|
||||
idInco: $idInco,
|
||||
identification: $this->hydrateIdentification($model),
|
||||
energie: $this->hydrateEnergie($model),
|
||||
macronutrimentsRef: $this->hydrateMacronutrimentsRef($model),
|
||||
macronutrimentsPortion: $this->hydrateMacronutrimentsPortion($model),
|
||||
fnl: $this->hydrateFnl($model),
|
||||
apportsReference: $this->hydrateApportsReference($model),
|
||||
nutriScore: $this->hydrateNutriScore($model),
|
||||
pointsNutriScore: $this->hydratePointsNutriScore($model),
|
||||
mineraux: $this->hydrateMineraux($model),
|
||||
vitamines: $this->hydrateVitamines($model),
|
||||
glucidesDetail: $this->hydrateGlucidesDetail($model),
|
||||
acideGras: $this->hydrateAcideGras($model),
|
||||
acidesAmines: $this->hydrateAcidesAmines($model),
|
||||
composesSpeciaux: $this->hydrateComposesSpeciaux($model),
|
||||
identification: $this->mapIdentification($model),
|
||||
energie: $this->mapEnergie($model),
|
||||
macronutrimentsRef: $this->mapMacronutrimentsRef($model),
|
||||
macronutrimentsPortion: $this->mapMacronutrimentsPortion($model),
|
||||
fnl: $this->mapFnl($model),
|
||||
apportsReference: $this->mapApportsReference($model),
|
||||
nutriScore: $this->mapNutriScore($model),
|
||||
pointsNutriScore: $this->mapPointsNutriScore($model),
|
||||
mineraux: $this->mapMineraux($model),
|
||||
vitamines: $this->mapVitamines($model),
|
||||
glucidesDetail: $this->mapGlucidesDetail($model),
|
||||
acideGras: $this->mapAcideGras($model),
|
||||
acidesAmines: $this->mapAcidesAmines($model),
|
||||
composesSpeciaux: $this->mapComposesSpeciaux($model),
|
||||
);
|
||||
}
|
||||
|
||||
private function hydrateIdentification(KiotaIncoCompo $model): Identification
|
||||
private function mapIdentification(KiotaIncoCompo $model): Identification
|
||||
{
|
||||
$ident = $model->getIdentification();
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateEnergie(KiotaIncoCompo $model): Energie
|
||||
private function mapEnergie(KiotaIncoCompo $model): Energie
|
||||
{
|
||||
$energy = $model->getEnergy();
|
||||
$ref = $energy?->getReference();
|
||||
|
|
@ -82,7 +82,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateMacronutrimentsRef(KiotaIncoCompo $model): MacronutrimentsRef
|
||||
private function mapMacronutrimentsRef(KiotaIncoCompo $model): MacronutrimentsRef
|
||||
{
|
||||
$m = $model->getReferenceMacronutrients();
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateMacronutrimentsPortion(KiotaIncoCompo $model): MacronutrimentsPortion
|
||||
private function mapMacronutrimentsPortion(KiotaIncoCompo $model): MacronutrimentsPortion
|
||||
{
|
||||
$m = $model->getPortionMacronutrients();
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateFnl(KiotaIncoCompo $model): FruitLegumeNoix
|
||||
private function mapFnl(KiotaIncoCompo $model): FruitLegumeNoix
|
||||
{
|
||||
$fnl = $model->getFreshProduceAndNuts();
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateApportsReference(KiotaIncoCompo $model): ApportsReference
|
||||
private function mapApportsReference(KiotaIncoCompo $model): ApportsReference
|
||||
{
|
||||
$ri = $model->getReferenceIntakes();
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateNutriScore(KiotaIncoCompo $model): NutriScore
|
||||
private function mapNutriScore(KiotaIncoCompo $model): NutriScore
|
||||
{
|
||||
$ns = $model->getNutriScore();
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydratePointsNutriScore(KiotaIncoCompo $model): PointsNutriScore
|
||||
private function mapPointsNutriScore(KiotaIncoCompo $model): PointsNutriScore
|
||||
{
|
||||
$nsp = $model->getNutriScorePoints();
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateMineraux(KiotaIncoCompo $model): Mineraux
|
||||
private function mapMineraux(KiotaIncoCompo $model): Mineraux
|
||||
{
|
||||
$m = $model->getMinerals();
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateVitamines(KiotaIncoCompo $model): Vitamines
|
||||
private function mapVitamines(KiotaIncoCompo $model): Vitamines
|
||||
{
|
||||
$v = $model->getVitamins();
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateGlucidesDetail(KiotaIncoCompo $model): GlucidesDetail
|
||||
private function mapGlucidesDetail(KiotaIncoCompo $model): GlucidesDetail
|
||||
{
|
||||
$cd = $model->getCarbohydratesDetail();
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateAcideGras(KiotaIncoCompo $model): AcideGras
|
||||
private function mapAcideGras(KiotaIncoCompo $model): AcideGras
|
||||
{
|
||||
$fa = $model->getFattyAcids();
|
||||
|
||||
|
|
@ -329,7 +329,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateAcidesAmines(KiotaIncoCompo $model): AcidesAmines
|
||||
private function mapAcidesAmines(KiotaIncoCompo $model): AcidesAmines
|
||||
{
|
||||
$aa = $model->getAminoAcids();
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ final class IncoCompoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateComposesSpeciaux(KiotaIncoCompo $model): ComposesSpeciaux
|
||||
private function mapComposesSpeciaux(KiotaIncoCompo $model): ComposesSpeciaux
|
||||
{
|
||||
$sc = $model->getSpecialCompounds();
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Hydrator;
|
||||
namespace Uwil\ArcadiaApiPhpClient\Mapper;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Brand;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Inco;
|
||||
|
|
@ -27,7 +27,7 @@ use Uwil\ArcadiaKiotaOpenApiClient\Models\PaginationMeta;
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class IncoHydrator
|
||||
final class IncoMapper
|
||||
{
|
||||
public function toDto(KiotaInco $model): Inco
|
||||
{
|
||||
|
|
@ -36,21 +36,21 @@ final class IncoHydrator
|
|||
name: $model->getName() ?? '',
|
||||
libelle: $model->getLabel() ?? '',
|
||||
description: $model->getDescription() ?? '',
|
||||
allegations: $this->hydrateAllegations($model),
|
||||
allegations: $this->mapAllegations($model),
|
||||
sellArguments: $model->getSellArguments() ?? '',
|
||||
preparationAdvices: $model->getPreparationAdvices() ?? '',
|
||||
tips: $model->getTips(),
|
||||
sellFamilly: $model->getSellFamilly(),
|
||||
ingredients: $this->hydrateIngredients($model),
|
||||
portions: $this->hydratePortions($model),
|
||||
allergens: $this->hydrateAllergens($model),
|
||||
brand: $this->hydrateBrand($model),
|
||||
ingredients: $this->mapIngredients($model),
|
||||
portions: $this->mapPortions($model),
|
||||
allergens: $this->mapAllergens($model),
|
||||
brand: $this->mapBrand($model),
|
||||
isSeasonal: $model->getIsSeasonal() ?? false,
|
||||
weight: $this->hydrateWeight($model),
|
||||
nutriscore: $this->hydrateNutriscore($model),
|
||||
storageCondition: $this->hydrateStorageCondition($model),
|
||||
additives: $this->hydrateAdditives($model),
|
||||
compo: $this->hydrateCompoId($model),
|
||||
weight: $this->mapWeight($model),
|
||||
nutriscore: $this->mapNutriscore($model),
|
||||
storageCondition: $this->mapStorageCondition($model),
|
||||
additives: $this->mapAdditives($model),
|
||||
compo: $this->mapCompoId($model),
|
||||
createdAt: $model->getCreatedAt(),
|
||||
updatedAt: $model->getUpdatedAt(),
|
||||
);
|
||||
|
|
@ -69,10 +69,18 @@ final class IncoHydrator
|
|||
}
|
||||
}
|
||||
|
||||
return new PageOf($this->hydratePagination($response->getPagination(), $pagination), $items);
|
||||
$paginationDto = $this->paginationDto(
|
||||
$response->getPagination(),
|
||||
$pagination
|
||||
);
|
||||
|
||||
return new PageOf(
|
||||
$paginationDto,
|
||||
$items
|
||||
);
|
||||
}
|
||||
|
||||
private function hydratePagination(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
private function paginationDto(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
{
|
||||
return new PaginationDto(
|
||||
page: $meta?->getPage() ?? $pagination->pageNumber(),
|
||||
|
|
@ -82,7 +90,7 @@ final class IncoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateAllegations(KiotaInco $model): Allegations
|
||||
private function mapAllegations(KiotaInco $model): Allegations
|
||||
{
|
||||
$m = $model->getAllegations();
|
||||
|
||||
|
|
@ -94,14 +102,14 @@ final class IncoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateCompoId(KiotaInco $model): ?IncoCompoId
|
||||
private function mapCompoId(KiotaInco $model): ?IncoCompoId
|
||||
{
|
||||
$compoId = $model->getIncoCompoId();
|
||||
|
||||
return $compoId !== null && $compoId !== '' ? new IncoCompoId($compoId) : null;
|
||||
}
|
||||
|
||||
private function hydrateIngredients(KiotaInco $model): Ingredients
|
||||
private function mapIngredients(KiotaInco $model): Ingredients
|
||||
{
|
||||
$data = $model->getIngredients()?->getAdditionalData();
|
||||
if (! is_array($data) || empty($data)) {
|
||||
|
|
@ -138,9 +146,10 @@ final class IncoHydrator
|
|||
return $cleanLines;
|
||||
}
|
||||
|
||||
private function hydratePortions(KiotaInco $model): ?PortionAmount
|
||||
private function mapPortions(KiotaInco $model): ?PortionAmount
|
||||
{
|
||||
$portionAmount = $model->getPortions()?->getIncoPortionAmount();
|
||||
$portionAmount = $model->getPortions();
|
||||
|
||||
if ($portionAmount === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -155,7 +164,7 @@ final class IncoHydrator
|
|||
/**
|
||||
* @return Allergen[]
|
||||
*/
|
||||
private function hydrateAllergens(KiotaInco $model): array
|
||||
private function mapAllergens(KiotaInco $model): array
|
||||
{
|
||||
$allergens = [];
|
||||
$index = 1;
|
||||
|
|
@ -170,7 +179,7 @@ final class IncoHydrator
|
|||
return $allergens;
|
||||
}
|
||||
|
||||
private function hydrateBrand(KiotaInco $model): Brand
|
||||
private function mapBrand(KiotaInco $model): Brand
|
||||
{
|
||||
$brandModel = $model->getBrand();
|
||||
$codeStr = $brandModel?->getCode();
|
||||
|
|
@ -182,9 +191,10 @@ final class IncoHydrator
|
|||
return new Brand(new BrandCode($codeVal), $label);
|
||||
}
|
||||
|
||||
private function hydrateWeight(KiotaInco $model): ?IncoWeight
|
||||
private function mapWeight(KiotaInco $model): ?IncoWeight
|
||||
{
|
||||
$weightModel = $model->getWeight()?->getIncoWeight();
|
||||
$weightModel = $model->getWeight();
|
||||
|
||||
if ($weightModel === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -196,9 +206,9 @@ final class IncoHydrator
|
|||
);
|
||||
}
|
||||
|
||||
private function hydrateNutriscore(KiotaInco $model): ?Nutriscore
|
||||
private function mapNutriscore(KiotaInco $model): ?Nutriscore
|
||||
{
|
||||
$grade = $model->getNutriscore()?->getIncoNutriscore()?->getGrade()?->value();
|
||||
$grade = $model->getNutriscore()?->getGrade()?->value();
|
||||
if ($grade === null || $grade === '') {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -211,9 +221,9 @@ final class IncoHydrator
|
|||
return new Nutriscore($upper);
|
||||
}
|
||||
|
||||
private function hydrateStorageCondition(KiotaInco $model): ?StorageCondition
|
||||
private function mapStorageCondition(KiotaInco $model): ?StorageCondition
|
||||
{
|
||||
$instructions = $model->getStorageCondition()?->getIncoStorageCondition()?->getInstructions();
|
||||
$instructions = $model->getStorageCondition()?->getInstructions();
|
||||
if ($instructions === null || mb_trim($instructions) === '') {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -224,7 +234,7 @@ final class IncoHydrator
|
|||
/**
|
||||
* @return Additive[]
|
||||
*/
|
||||
private function hydrateAdditives(KiotaInco $model): array
|
||||
private function mapAdditives(KiotaInco $model): array
|
||||
{
|
||||
$additives = [];
|
||||
foreach ($model->getAdditives() ?? [] as $additiveModel) {
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Uwil\ArcadiaApiPhpClient\Hydrator;
|
||||
namespace Uwil\ArcadiaApiPhpClient\Mapper;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
|
|
@ -16,15 +16,15 @@ use Uwil\ArcadiaKiotaOpenApiClient\Models\PaginationMeta;
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class IncoShortHydrator
|
||||
final class IncoShortMapper
|
||||
{
|
||||
public function toDto(KiotaIncoShort $model): IncoShort
|
||||
{
|
||||
return new IncoShort(
|
||||
id: new IncoId($model->getIncoId() ?? '0'),
|
||||
name: $model->getName() ?? '',
|
||||
libelle: $model->getLabel() ?? '',
|
||||
description: '',
|
||||
name: $model->getName() ?? '',
|
||||
libelle: $model->getLabel() ?? '',
|
||||
description: $model->getDescription() ?? '',
|
||||
created_at: $model->getCreatedAt(),
|
||||
updated_at: $model->getUpdatedAt(),
|
||||
);
|
||||
|
|
@ -43,10 +43,18 @@ final class IncoShortHydrator
|
|||
}
|
||||
}
|
||||
|
||||
return new PageOf($this->hydratePagination($response->getPagination(), $pagination), $items);
|
||||
$paginationDto = $this->paginationDto(
|
||||
$response->getPagination(),
|
||||
$pagination
|
||||
);
|
||||
|
||||
return new PageOf(
|
||||
$paginationDto,
|
||||
$items
|
||||
);
|
||||
}
|
||||
|
||||
private function hydratePagination(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
private function paginationDto(?PaginationMeta $meta, Pagination $pagination): PaginationDto
|
||||
{
|
||||
return new PaginationDto(
|
||||
page: $meta?->getPage() ?? $pagination->pageNumber(),
|
||||
|
|
@ -5,11 +5,11 @@ declare(strict_types=1);
|
|||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\BrandHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Brand;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination\Pagination;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\BrandMapper;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Brands\BrandsRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Brands\BrandsRequestBuilderGetRequestConfiguration;
|
||||
|
|
@ -21,7 +21,7 @@ final class BrandApiRepository extends AbstractApiRepository implements BrandRep
|
|||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly BrandHydrator $hydrator,
|
||||
private readonly BrandMapper $mapper,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ final class BrandApiRepository extends AbstractApiRepository implements BrandRep
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
public function find(BrandCode $code): Brand | null | ApiError
|
||||
|
|
@ -65,6 +65,6 @@ final class BrandApiRepository extends AbstractApiRepository implements BrandRep
|
|||
return null;
|
||||
}
|
||||
|
||||
return $this->hydrator->toDto($brandModel);
|
||||
return $this->mapper->toDto($brandModel);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\EmployeeHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Employee;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\EmployeeSortColumn;
|
||||
|
|
@ -13,6 +12,7 @@ use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\EmployeeSorter;
|
|||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\ArcadiaEmployeeId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\SiteId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination\Pagination;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\EmployeeMapper;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Employees\EmployeesRequestBuilderGetQueryParameters;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\Employees\EmployeesRequestBuilderGetRequestConfiguration;
|
||||
|
|
@ -26,7 +26,7 @@ final class EmployeeApiRepository extends AbstractApiRepository implements Emplo
|
|||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly EmployeeHydrator $hydrator,
|
||||
private readonly EmployeeMapper $mapper,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ final class EmployeeApiRepository extends AbstractApiRepository implements Emplo
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +84,7 @@ final class EmployeeApiRepository extends AbstractApiRepository implements Emplo
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,7 +114,7 @@ final class EmployeeApiRepository extends AbstractApiRepository implements Emplo
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -146,7 +146,7 @@ final class EmployeeApiRepository extends AbstractApiRepository implements Emplo
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
public function find(ArcadiaEmployeeId $id): Employee | null | ApiError
|
||||
|
|
@ -156,7 +156,7 @@ final class EmployeeApiRepository extends AbstractApiRepository implements Emplo
|
|||
$response = $this->apiClient->employees()->byEmployeeId($id->value)->get()->wait();
|
||||
$employee = $response?->getEmployee();
|
||||
|
||||
return $employee !== null ? $this->hydrator->toDto($employee) : null;
|
||||
return $employee !== null ? $this->mapper->toDto($employee) : null;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\Inco;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSortColumn;
|
||||
|
|
@ -13,6 +12,7 @@ use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSorter;
|
|||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination\Pagination;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\IncoMapper;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortByQueryParameterType;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortDirectionQueryParameterType;
|
||||
|
|
@ -28,7 +28,7 @@ final class IncoApiRepository extends AbstractApiRepository implements IncoRepos
|
|||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly IncoHydrator $hydrator,
|
||||
private readonly IncoMapper $mapper,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ final class IncoApiRepository extends AbstractApiRepository implements IncoRepos
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,7 +88,7 @@ final class IncoApiRepository extends AbstractApiRepository implements IncoRepos
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -119,7 +119,7 @@ final class IncoApiRepository extends AbstractApiRepository implements IncoRepos
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,7 +152,7 @@ final class IncoApiRepository extends AbstractApiRepository implements IncoRepos
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -179,7 +179,7 @@ final class IncoApiRepository extends AbstractApiRepository implements IncoRepos
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
public function find(IncoId $id): Inco | null | ApiError
|
||||
|
|
@ -189,7 +189,7 @@ final class IncoApiRepository extends AbstractApiRepository implements IncoRepos
|
|||
$response = $this->apiClient->incoSheets()->byIncoId($id->value)->get()->wait();
|
||||
$sheet = $response?->getIncoSheet();
|
||||
|
||||
return $sheet !== null ? $this->hydrator->toDto($sheet) : null;
|
||||
return $sheet !== null ? $this->mapper->toDto($sheet) : null;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ declare(strict_types=1);
|
|||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoCompoHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoCompo;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoCompoId;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\IncoId;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\IncoCompoMapper;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
|
||||
/**
|
||||
|
|
@ -18,7 +18,7 @@ final class IncoCompoApiRepository extends AbstractApiRepository implements Inco
|
|||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly IncoCompoHydrator $hydrator,
|
||||
private readonly IncoCompoMapper $mapper,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ final class IncoCompoApiRepository extends AbstractApiRepository implements Inco
|
|||
$response = $this->apiClient->incoSheets()->byIncoId($id->value)->composition()->get()->wait();
|
||||
$composition = $response?->getComposition();
|
||||
|
||||
return $composition !== null ? $this->hydrator->toDto($composition) : null;
|
||||
return $composition !== null ? $this->mapper->toDto($composition) : null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ declare(strict_types=1);
|
|||
namespace Uwil\ArcadiaApiPhpClient\Repository;
|
||||
|
||||
use Uwil\ArcadiaApiPhpClient\Error\ApiError;
|
||||
use Uwil\ArcadiaApiPhpClient\Hydrator\IncoShortHydrator;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\PageOf;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSortColumn;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSorter;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\ApiValueObject\BrandCode;
|
||||
use Uwil\ArcadiaApiPhpClient\Lib\Pagination\Pagination;
|
||||
use Uwil\ArcadiaApiPhpClient\Mapper\IncoShortMapper;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\ApiClient;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortByQueryParameterType;
|
||||
use Uwil\ArcadiaKiotaOpenApiClient\IncoSheets\GetSortDirectionQueryParameterType;
|
||||
|
|
@ -26,7 +26,7 @@ final class IncoShortApiRepository extends AbstractApiRepository implements Inco
|
|||
{
|
||||
public function __construct(
|
||||
ApiClient $apiClient,
|
||||
private readonly IncoShortHydrator $hydrator,
|
||||
private readonly IncoShortMapper $mapper,
|
||||
) {
|
||||
parent::__construct($apiClient);
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ final class IncoShortApiRepository extends AbstractApiRepository implements Inco
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,7 +88,7 @@ final class IncoShortApiRepository extends AbstractApiRepository implements Inco
|
|||
return $response;
|
||||
}
|
||||
|
||||
return $this->hydrator->toPage($response, $pagination);
|
||||
return $this->mapper->toPage($response, $pagination);
|
||||
}
|
||||
|
||||
private function mapSortBy(IncoSortColumn $column): GetSortByQueryParameterType
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue