Skip to content

Commit

Permalink
Avoid requiring PHP8.3 for now
Browse files Browse the repository at this point in the history
  • Loading branch information
sroehrl committed Mar 29, 2024
1 parent 109b7c4 commit 3dacd5f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Helper/VerifyJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

use JsonException;
use JsonSerializable;
use Neoan\Model\Collection;
use Neoan\Model\Model;

class VerifyJson implements JsonSerializable
{
Expand All @@ -17,9 +15,14 @@ public function __construct(mixed $data)
$this->data = $data;
}

static function isJson(string $string): bool
static function isJson(string $string, $depth = 512, $flags = 0): bool
{
return json_validate($string);
try {
json_decode($string, false, $depth, $flags | JSON_THROW_ON_ERROR);
return true;
} catch (JsonException $e) {
return false;
}
}

/**
Expand Down

0 comments on commit 3dacd5f

Please sign in to comment.