Skip to content

Commit dfd3f56

Browse files
author
Fredrick Peter
committed
Collection Json Error Update
1 parent 7b3fed6 commit dfd3f56

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ was pretty tough. So i decided to create a much more easier way of communicating
107107

108108
## Requirements
109109

110-
- `>= php7.2+`
110+
- `>= php7.2.5+`
111111

112112
## Installation
113113

composer.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.2",
19+
"php": ">=7.2.5",
2020
"vlucas/phpdotenv": "^5.3",
2121
"ezyang/htmlpurifier": "^4.16.0",
2222
"symfony/var-dumper": "^4.4",
2323
"filp/whoops": "^2.15",
2424
"psr/log": "^1.1.4"
2525
},
26-
"config": {
27-
"platform": {
28-
"php": "7.2"
29-
}
30-
},
3126
"autoload": {
3227
"files": [
3328
"src/helpers.php"

src/Collections/Traits/RelatedTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ private function convertMapperOnInit(mixed $items = null)
229229
{
230230
if (self::$is_paginate) {
231231
return json_decode(json_encode($items), true);
232-
} elseif ($this->isValidJson($items)) {
233-
return json_decode($items, true);
234232
} elseif (is_array($items)) {
235233
return $items;
234+
} elseif ($this->isValidJson((string) $items)) {
235+
return json_decode($items, true);
236236
}
237237

238-
return (array) $items;
238+
return $items;
239239
}
240240

241241
/**
@@ -249,11 +249,11 @@ private function convertOnInit(mixed $items = null)
249249
// first or insert request
250250
if ($this->unescapeIsObjectWithoutArray) {
251251
return json_decode(json_encode($items), true);
252-
} elseif($this->isValidJson($items)) {
253-
return json_decode($items, true);
254252
} elseif(is_array($items)){
255253
return $items;
256-
}
254+
} elseif($this->isValidJson((string) $items)) {
255+
return json_decode($items, true);
256+
}
257257

258258
return $items;
259259
}
@@ -266,7 +266,7 @@ private function convertOnInit(mixed $items = null)
266266
*/
267267
private function isValidJson(?string $data = null)
268268
{
269-
json_decode((string) $data);
269+
json_decode($data);
270270
return json_last_error() === JSON_ERROR_NONE;
271271
}
272272

0 commit comments

Comments
 (0)