| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: #2 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Malio\EdnotifBundle\Bovin\Mapper;
|
|
|
|
use Malio\EdnotifBundle\Bovin\Dto\AnimalFileDto;
|
|
use Malio\EdnotifBundle\Shared\Mapper\StandardResponseMapper;
|
|
|
|
final class AnimalFileMapper
|
|
{
|
|
use BovinNodeMappingTrait;
|
|
|
|
public function __construct(
|
|
private readonly StandardResponseMapper $standardResponseMapper,
|
|
) {}
|
|
|
|
public function map(object $soapResponse): AnimalFileDto
|
|
{
|
|
$standardResponse = $this->standardResponseMapper->map($soapResponse->ReponseStandard ?? null);
|
|
|
|
$specificResponseNode = $soapResponse->ReponseSpecifique ?? null;
|
|
$bovinNode = is_object($specificResponseNode) ? ($specificResponseNode->Bovin ?? null) : null;
|
|
|
|
$identification = null;
|
|
$presencePeriods = [];
|
|
|
|
if (is_object($bovinNode)) {
|
|
$identificationNode = $bovinNode->IdentiteBovin ?? null;
|
|
if (is_object($identificationNode)) {
|
|
$identification = $this->mapIdentification($identificationNode);
|
|
}
|
|
|
|
$presencePeriodsNode = $bovinNode->PeriodesPresences->PeriodePresence ?? null;
|
|
foreach ($this->normalizeToList($presencePeriodsNode) as $presencePeriodNode) {
|
|
if (!is_object($presencePeriodNode)) {
|
|
continue;
|
|
}
|
|
$presencePeriods[] = $this->mapPresencePeriod($presencePeriodNode);
|
|
}
|
|
}
|
|
|
|
return new AnimalFileDto(
|
|
standardResponse: $standardResponse,
|
|
identification: $identification,
|
|
presencePeriods: $presencePeriods,
|
|
rawSoapResponse: $soapResponse
|
|
);
|
|
}
|
|
}
|