Skip to content

Commit e8bbb95

Browse files
committed
Removed superfluous JSON serialization
1 parent b679bc0 commit e8bbb95

12 files changed

Lines changed: 1 addition & 142 deletions

File tree

src/Model/AbstractF2Item.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,4 @@ public function apiSerialize(): array
4141
{
4242
return [];
4343
}
44-
45-
/**
46-
* Serialize with the names (paths) needed for JSON patch.
47-
*
48-
* Only names starting with a capital letter will be included in JSON patch'ing (cf. self::filterForJsonPatch).
49-
*
50-
* @see self::filterForJsonPatch()
51-
*/
52-
#[\Override]
53-
public function jsonSerialize(): array
54-
{
55-
return $this->apiSerialize()
56-
+ [
57-
'id' => $this->id,
58-
'links' => $this->links->jsonSerialize(),
59-
];
60-
}
6144
}

src/Model/AbstractItem.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace ItkDev\F2ApiClient\Model;
66

7-
abstract class AbstractItem implements \JsonSerializable
7+
abstract class AbstractItem
88
{
99
public static function fromSimpleXMLElement(\SimpleXMLElement $sxe): static
1010
{
@@ -46,14 +46,4 @@ protected function createDateTime(\SimpleXMLElement|string $value): \DateTimeImm
4646

4747
return (new \DateTimeImmutable((string) $value, $apiTimeZone))->setTimeZone($appTimeZone);
4848
}
49-
50-
/**
51-
* @return array<string, mixed>
52-
*/
53-
abstract public function jsonSerialize(): array;
54-
55-
protected function jsonSerializeDateTime(?\DateTimeImmutable $dateTime): ?string
56-
{
57-
return $dateTime?->format(\DateTimeInterface::ATOM);
58-
}
5949
}

src/Model/Atom.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,4 @@ public function __toString(): string
2828
{
2929
return sprintf('%s (%s)', $this->title, $this->id);
3030
}
31-
32-
#[\Override]
33-
public function jsonSerialize(): array
34-
{
35-
return [
36-
'id' => $this->id,
37-
'title' => $this->title,
38-
'published' => $this->jsonSerializeDateTime($this->published),
39-
'updated' => $this->jsonSerializeDateTime($this->updated),
40-
];
41-
}
4231
}

src/Model/CaseFile.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,4 @@ public function apiSerialize(): array
5555
'Deadline' => $this->deadline,
5656
];
5757
}
58-
59-
#[\Override]
60-
public function jsonSerialize(): array
61-
{
62-
return [
63-
'journalPlan' => $this->journalPlan?->jsonSerialize(),
64-
'processInstruction' => $this->processInstruction?->jsonSerialize(),
65-
'createdDate' => $this->jsonSerializeDateTime($this->createdDate),
66-
'modifiedDate' => $this->jsonSerializeDateTime($this->modifiedDate),
67-
'modifiedBy' => $this->modifiedBy?->jsonSerialize(),
68-
'responsible' => $this->responsible?->jsonSerialize(),
69-
] + parent::jsonSerialize();
70-
}
7158
}

src/Model/Collection.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,4 @@ public function setFromSimpleXMLElement(\SimpleXMLElement $sxe): static
2929

3030
return $this;
3131
}
32-
33-
#[\Override]
34-
public function jsonSerialize(): array
35-
{
36-
return [
37-
'title' => $this->title,
38-
'items' => array_map(static fn (Item $item) => $item->jsonSerialize(), $this->items),
39-
];
40-
}
4132
}

src/Model/Collection/Item.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,4 @@ public function __toString(): string
2525
{
2626
return sprintf('%s (#%d)', $this->title, $this->id);
2727
}
28-
29-
#[\Override]
30-
public function jsonSerialize(): array
31-
{
32-
return [
33-
'title' => $this->title,
34-
];
35-
}
3628
}

src/Model/Document.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,4 @@ public function apiSerialize(): array
4040
'Description' => $this->description,
4141
];
4242
}
43-
44-
#[\Override]
45-
public function jsonSerialize(): array
46-
{
47-
return [
48-
'createdDate' => $this->jsonSerializeDateTime($this->createdDate),
49-
'modifiedDate' => $this->jsonSerializeDateTime($this->modifiedDate),
50-
] + parent::jsonSerialize();
51-
}
5243
}

src/Model/F2Item/Links.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,4 @@ public function getUrl(string $rel): string
7474

7575
return $link['href'];
7676
}
77-
78-
#[\Override]
79-
public function jsonSerialize(): array
80-
{
81-
return $this->links;
82-
}
8377
}

src/Model/JournalPlan.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,4 @@ public function setFromSimpleXMLElement(\SimpleXMLElement $sxe): static
2222

2323
return $this;
2424
}
25-
26-
#[\Override]
27-
public function jsonSerialize(): array
28-
{
29-
$serialized =
30-
[
31-
'title' => $this->title,
32-
'path' => $this->path,
33-
'code' => $this->code,
34-
] + parent::jsonSerialize();
35-
36-
// JournalPlan doesn't have an ID.
37-
unset($serialized['id']);
38-
39-
return $serialized;
40-
}
4125
}

src/Model/Matter.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,4 @@ public function apiSerialize(): array
5454
'Type' => $this->type,
5555
];
5656
}
57-
58-
#[\Override]
59-
public function jsonSerialize(): array
60-
{
61-
return [
62-
'matterNumber' => $this->matterNumber,
63-
'caseNumber' => $this->caseNumber,
64-
'createdDate' => $this->jsonSerializeDateTime($this->createdDate),
65-
'modifiedDate' => $this->jsonSerializeDateTime($this->modifiedDate),
66-
'createdBy' => $this->createdBy?->jsonSerialize(),
67-
'modifiedBy' => $this->modifiedBy?->jsonSerialize(),
68-
'responsible' => $this->responsible?->jsonSerialize(),
69-
] + parent::jsonSerialize();
70-
}
7157
}

0 commit comments

Comments
 (0)