Skip to content

Commit 6f8f00d

Browse files
refactor: Jsonable::toJson() can now be run with JsonStrategy
refs #8
1 parent 5614529 commit 6f8f00d

30 files changed

+390
-27
lines changed

src/Core/ParameterBag.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Conjoon\Util\ArrayUtil;
3333
use BadMethodCallException;
3434
use Conjoon\Util\Jsonable;
35+
use Conjoon\Util\JsonStrategy;
3536

3637
/**
3738
* A ParameterBag providing object syntax for accessing array arguments and
@@ -172,7 +173,7 @@ public function keys()
172173
*
173174
* @return array
174175
*/
175-
public function toJson(): array
176+
public function toJson(JsonStrategy $strategy = null): array
176177
{
177178
return json_decode(json_encode($this->data), true);
178179
}

src/Core/ResourceQuery.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
use BadMethodCallException;
3333
use Conjoon\Util\Jsonable;
34+
use Conjoon\Util\JsonStrategy;
3435

3536
/**
3637
* A ResourceQuery provides an interface for a validated and certified collection
@@ -107,7 +108,7 @@ public function has($key): bool
107108
*
108109
* @return array
109110
*/
110-
public function toJson(): array
111+
public function toJson(JsonStrategy $strategy = null): array
111112
{
112113
return $this->parameters->toJson();
113114
}

src/Http/Json/Problem/AbstractProblem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
use BadMethodCallException;
3333
use Conjoon\Util\Jsonable;
34+
use Conjoon\Util\JsonStrategy;
3435

3536
/**
3637
* Abstract base class for representatives according to rfc7807.
@@ -146,7 +147,7 @@ public function __call(string $method, $arguments)
146147
*
147148
* @return array
148149
*/
149-
public function toJson(): array
150+
public function toJson(JsonStrategy $strategy = null): array
150151
{
151152
$data = [
152153
"status" => $this->status,

src/Mail/Client/Attachment/AbstractAttachment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use BadMethodCallException;
3333
use Conjoon\Mail\Client\Data\CompoundKey\AttachmentKey;
3434
use Conjoon\Util\Jsonable;
35+
use Conjoon\Util\JsonStrategy;
3536
use InvalidArgumentException;
3637

3738
/**
@@ -155,7 +156,7 @@ public function setSize(int $size)
155156
/**
156157
* @inheritdoc
157158
*/
158-
public function toJson(): array
159+
public function toJson(JsonStrategy $strategy = null): array
159160
{
160161
return array_merge(
161162
$this->attachmentKey ? $this->attachmentKey->toJson() : [],

src/Mail/Client/Attachment/FileAttachment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
use Conjoon\Mail\Client\Data\CompoundKey\AttachmentKey;
3333
use Conjoon\Util\ArrayUtil;
34+
use Conjoon\Util\JsonStrategy;
3435
use InvalidArgumentException;
3536

3637
/**
@@ -124,7 +125,7 @@ public function setAttachmentKey(AttachmentKey $attachmentKey): FileAttachment
124125
/**
125126
* @inheritdoc
126127
*/
127-
public function toJson(): array
128+
public function toJson(JsonStrategy $strategy = null): array
128129
{
129130
return array_merge(parent::toJson(), [
130131
"content" => $this->getContent(),

src/Mail/Client/Attachment/FileAttachmentItem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
namespace Conjoon\Mail\Client\Attachment;
3131

3232
use Conjoon\Mail\Client\Data\CompoundKey\AttachmentKey;
33+
use Conjoon\Util\JsonStrategy;
3334
use InvalidArgumentException;
3435

3536
/**
@@ -91,7 +92,7 @@ public function __construct(AttachmentKey $attachmentKey, array $data)
9192
/**
9293
* @inheritdoc
9394
*/
94-
public function toJson(): array
95+
public function toJson(JsonStrategy $strategy = null): array
9596
{
9697

9798
return array_merge(parent::toJson(), [

src/Mail/Client/Attachment/FileAttachmentItemList.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
use Conjoon\Util\AbstractList;
3333
use Conjoon\Util\Jsonable;
34+
use Conjoon\Util\JsonStrategy;
3435

3536
/**
3637
* Class FileAttachmentItemList organizes a list of FileAttachmentItems.
@@ -60,7 +61,7 @@ public function getEntityType(): string
6061
/**
6162
* @return array
6263
*/
63-
public function toJson(): array
64+
public function toJson(JsonStrategy $strategy = null): array
6465
{
6566

6667
$data = [];

src/Mail/Client/Attachment/FileAttachmentList.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
use Conjoon\Util\AbstractList;
3333
use Conjoon\Util\Jsonable;
34+
use Conjoon\Util\JsonStrategy;
3435

3536
/**
3637
* Class FileAttachmentList organizes a list of FileAttachments.
@@ -51,7 +52,7 @@ public function getEntityType(): string
5152
/**
5253
* @return array
5354
*/
54-
public function toJson(): array
55+
public function toJson(JsonStrategy $strategy = null): array
5556
{
5657

5758
$data = [];

src/Mail/Client/Data/CompoundKey/CompoundKey.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
use Conjoon\Mail\Client\Data\MailAccount;
3333
use Conjoon\Util\Jsonable;
34+
use Conjoon\Util\JsonStrategy;
3435
use Conjoon\Util\Stringable;
3536

3637
/**
@@ -96,7 +97,7 @@ public function getId(): string
9697
*
9798
* @return array
9899
*/
99-
public function toJson(): array
100+
public function toJson(JsonStrategy $strategy = null): array
100101
{
101102
return [
102103
'id' => $this->getId(),

src/Mail/Client/Data/CompoundKey/MessageItemChildCompoundKey.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
namespace Conjoon\Mail\Client\Data\CompoundKey;
3131

32+
use Conjoon\Util\JsonStrategy;
3233
use InvalidArgumentException;
3334

3435
/**
@@ -124,7 +125,7 @@ public function equals(MessageItemChildCompoundKey $key): bool
124125
*
125126
* @return array
126127
*/
127-
public function toJson(): array
128+
public function toJson(JsonStrategy $strategy = null): array
128129
{
129130
$json = parent::toJson();
130131
$json["parentMessageItemId"] = $this->getParentMessageItemId();

0 commit comments

Comments
 (0)