class IsJson extends StringComparator (View source)

Checks if a string is a valid JSON string.

Traits

Methods

__construct(int $depth = 512, int $flags = 0)

No description

bool
__invoke(mixed $value)

Compare the input value against the comparator.

bool
check(mixed $value)

Compare the input string against the comparator.

bool
checkString(string $value)

Compare the input string against the comparator.

static IsJson
make(int $depth = 512, int $flags = 0)

No description

string
resolveStringInput(mixed $value)

No description

Details

__construct(int $depth = 512, int $flags = 0)

No description

Parameters

int $depth

Maximum depth of the JSON string (default: 512).

int $flags

Bitmask of JSON decode flags. JSON_THROW_ON_ERROR is not allowed and will be stripped if applied (default: 0).

final bool __invoke(mixed $value)

Compare the input value against the comparator.

Parameters

mixed $value

Return Value

bool

final bool check(mixed $value)

Compare the input string against the comparator.

Parameters

mixed $value

Return Value

bool

protected bool checkString(string $value)

Compare the input string against the comparator.

Parameters

string $value

Return Value

bool

static IsJson make(int $depth = 512, int $flags = 0)

No description

Parameters

int $depth

Maximum depth of the JSON string (default: 512).

int $flags

Bitmask of JSON decode flags. JSON_THROW_ON_ERROR is not allowed and will be stripped if applied (default: 0).

Return Value

IsJson

protected string resolveStringInput(mixed $value)

No description

Parameters

mixed $value

Return Value

string