Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinx13 committed Sep 19, 2023
2 parents ee361f2 + 056baba commit e21b6b9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Factory/Esabora/DossierMessageSCHSFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function createInstance(Affectation $affectation): DossierMessageSCHS
$signalement = $affectation->getSignalement();
$partner = $affectation->getPartner();
$address = AddressParser::parse($signalement->getAdresseOccupant());
$etage = $signalement->getEtageOccupant() ? EtageParser::parse($signalement->getEtageOccupant()) : null;

return (new DossierMessageSCHS())
->setUrl($partner->getEsaboraUrl())
Expand All @@ -42,7 +43,7 @@ public function createInstance(Affectation $affectation): DossierMessageSCHS
->setAdresseSignalement($address['street'])
->setCodepostaleSignalement($signalement->getCpOccupant())
->setVilleSignalement($signalement->getVilleOccupant())
->setEtageSignalement(EtageParser::parse($signalement->getEtageOccupant()))
->setEtageSignalement($etage)
->setNumeroAppartementSignalement($signalement->getNumAppartOccupant())
->setNumeroAdresseSignalement($address['number'])
->setLatitudeSignalement($signalement->getGeoloc()['lat'] ?? 0)
Expand Down
4 changes: 3 additions & 1 deletion src/Factory/Esabora/DossierMessageSISHFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function createInstance(Affectation $affectation): DossierMessageSISH
? implode(',', $signalement->getModeContactProprio())
: null;

$etage = $signalement->getEtageOccupant() ? EtageParser::parse($signalement->getEtageOccupant()) : null;

return (new DossierMessageSISH())
->setUrl($partner->getEsaboraUrl())
->setToken($partner->getEsaboraToken())
Expand All @@ -86,7 +88,7 @@ public function createInstance(Affectation $affectation): DossierMessageSISH
?->setTimezone(new \DateTimeZone(self::DEFAULT_TIMEZONE))
->format($formatDateTime)
)
->setLocalisationEtage(EtageParser::parse($signalement->getEtageOccupant()))
->setLocalisationEtage($etage)
->setLocalisationEscalier($signalement->getEscalierOccupant())
->setLocalisationNumPorte($signalement->getNumAppartOccupant())
->setSitOccupantNbAdultes($signalement->getNbAdultes())
Expand Down
4 changes: 2 additions & 2 deletions src/Form/SignalementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder->get('etageOccupant')
->addModelTransformer(new CallbackTransformer(
function ($currentEtage): ?int {
return EtageParser::parse($currentEtage);
return $currentEtage ? EtageParser::parse($currentEtage) : null;
},
function ($updtatedEtage): string {
function ($updtatedEtage): ?string {
return $updtatedEtage;
}
));
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/EtageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class EtageParser
{
public static function parse(?string $etage): ?int
public static function parse(string $etage): ?int
{
if (preg_match('/(rez|rdc|rdj|rh|chauss)/i', $etage, $matches)) {
return 0;
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Utils/EtageParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,5 @@ public function provideEtage(): \Generator
yield '4ème étage - entrée 1' => ['4ème étage - entrée 1', 4];

yield 'Dernière maison à gauche' => ['Dernière maison à gauche', null];

yield 'null' => [null, null];
}
}

0 comments on commit e21b6b9

Please sign in to comment.