Skip to content

Commit 09e634c

Browse files
committed
Cleaned up datetime serialization
1 parent c0cc82d commit 09e634c

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/Model/AbstractF2Item.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,4 @@ public function jsonSerialize(): array
4040
'links' => $this->links->jsonSerialize(),
4141
];
4242
}
43-
44-
protected function serializeDateTime(?\DateTimeImmutable $dateTime): ?string
45-
{
46-
return $dateTime?->format(\DateTimeInterface::ATOM);
47-
}
4843
}

src/Model/AbstractItem.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ protected function createDateTime(\SimpleXMLElement|string $value): \DateTimeImm
4646

4747
return (new \DateTimeImmutable((string) $value, $apiTimeZone))->setTimeZone($appTimeZone);
4848
}
49+
50+
protected function jsonSerializeDateTime(?\DateTimeImmutable $dateTime): ?string
51+
{
52+
return $dateTime?->format(\DateTimeInterface::ATOM);
53+
}
4954
}

src/Model/Atom.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function jsonSerialize(): array
3535
return [
3636
'id' => $this->id,
3737
'title' => $this->title,
38-
'published' => $this->published->format(\DateTimeInterface::ATOM),
39-
'updated' => $this->updated->format(\DateTimeInterface::ATOM),
38+
'published' => $this->jsonSerializeDateTime($this->published),
39+
'updated' => $this->jsonSerializeDateTime($this->updated),
4040
];
4141
}
4242
}

src/Model/CaseFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function jsonSerialize(): array
6868
'JournalPlan' => $this->journalPlan->jsonSerialize(),
6969
'ProcessInstruction' => $this->processInstruction->jsonSerialize(),
7070
'Deadline' => $this->deadline,
71-
'CreatedDate' => $this->createdDate,
72-
'ModifiedDate' => $this->modifiedDate,
71+
'CreatedDate' => $this->jsonSerializeDateTime($this->createdDate),
72+
'ModifiedDate' => $this->jsonSerializeDateTime($this->modifiedDate),
7373
'ModifiedBy' => $this->modifiedBy->jsonSerialize(),
7474
'Responsible' => $this->responsible?->jsonSerialize(),
7575
'Matters' => array_map(static fn (Matter $matter) => $matter->jsonSerialize(), $this->matters),

src/Model/Document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function jsonSerialize(): array
3838
return [
3939
'Title' => $this->title,
4040
'Description' => $this->description,
41-
'CreatedDate' => $this->serializeDateTime($this->createdDate),
42-
'ModifiedDate' => $this->serializeDateTime($this->modifiedDate),
41+
'CreatedDate' => $this->jsonSerializeDateTime($this->createdDate),
42+
'ModifiedDate' => $this->jsonSerializeDateTime($this->modifiedDate),
4343
] + parent::jsonSerialize();
4444
}
4545
}

src/Model/Matter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function jsonSerialize(): array
5555
'Title' => $this->title,
5656
'Type' => $this->type,
5757
'CaseNumber' => $this->caseNumber,
58-
'CreatedDate' => $this->serializeDateTime($this->createdDate),
59-
'ModifiedDate' => $this->serializeDateTime($this->modifiedDate),
58+
'CreatedDate' => $this->jsonSerializeDateTime($this->createdDate),
59+
'ModifiedDate' => $this->jsonSerializeDateTime($this->modifiedDate),
6060
'CreatedBy' => $this->createdBy->jsonSerialize(),
6161
'ModifiedBy' => $this->modifiedBy->jsonSerialize(),
6262
'Responsible' => $this->responsible?->jsonSerialize(),

0 commit comments

Comments
 (0)