Files
ednotif-bundle/src/Bovin/Mapper/AnimalFileMapper.php
tristan f757822f36
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
Build Release Artefact / build (push) Successful in 39s
[#ED-1] Ajout des API de lecture bovin (#2)
| 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>
2026-04-21 08:14:37 +00:00

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
);
}
}