Skip to content

Commit 82afba3

Browse files
committed
PrivateIdentification::$birthDate is a DateTimeImmutable
1 parent 191f4d6 commit 82afba3

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/DTO/PrivateIdentification.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
namespace Genkgo\Camt\DTO;
66

7+
use DateTimeImmutable;
8+
79
class PrivateIdentification extends Identification
810
{
9-
private ?string $birthDate = null;
11+
private ?DateTimeImmutable $birthDate = null;
1012

1113
private ?string $provinceOfBirth = null;
1214

@@ -20,12 +22,12 @@ class PrivateIdentification extends Identification
2022

2123
private ?string $otherSchemeName = null;
2224

23-
public function getBirthDate(): ?string
25+
public function getBirthDate(): ?DateTimeImmutable
2426
{
2527
return $this->birthDate;
2628
}
2729

28-
public function setBirthDate(?string $birthDate): void
30+
public function setBirthDate(?DateTimeImmutable $birthDate): void
2931
{
3032
$this->birthDate = $birthDate;
3133
}

src/Decoder/Factory/DTO/PrivateIdentification.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Genkgo\Camt\Decoder\Factory\DTO;
66

7+
use Genkgo\Camt\Decoder\Date;
78
use Genkgo\Camt\DTO;
89
use SimpleXMLElement;
910

@@ -14,7 +15,8 @@ public static function createFromXml(SimpleXMLElement $xmlPrivateIdentification)
1415
$privateIdentification = new DTO\PrivateIdentification();
1516
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth)) {
1617
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth->BirthDt)) {
17-
$privateIdentification->setBirthDate((string) $xmlPrivateIdentification->DtAndPlcOfBirth->BirthDt);
18+
$dateDecoder = new Date();
19+
$privateIdentification->setBirthDate($dateDecoder->decode((string) $xmlPrivateIdentification->DtAndPlcOfBirth->BirthDt));
1820
}
1921
if (isset($xmlPrivateIdentification->DtAndPlcOfBirth->PrvcOfBirth)) {
2022
$privateIdentification->setProvinceOfBirth((string) $xmlPrivateIdentification->DtAndPlcOfBirth->PrvcOfBirth);

test/data/camt053.v2.with-party-ids.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@
251251
},
252252
"getIdentification": {
253253
"__CLASS__": "Genkgo\\Camt\\DTO\\PrivateIdentification",
254-
"getBirthDate": "1912-12-12",
254+
"getBirthDate": {
255+
"__CLASS__": "DateTimeImmutable",
256+
"0": "1912-12-12T00:00:00+00:00"
257+
},
255258
"getCityOfBirth": "Göteborg",
256259
"getCountryOfBirth": "SE",
257260
"getIdentification": null,

0 commit comments

Comments
 (0)