AssertableJson
class AssertableJson implements Arrayable (View source)
Traits
Properties
protected array | $interacted | The list of interacted properties. |
from Interaction |
static protected array | $macros | The registered string macros. |
from Macroable |
Methods
Assert that the prop is of the expected size.
Assert that the prop size is between a given minimum and maximum.
Compose the absolute "dot" path to the given key.
Retrieve a prop within the current scope using "dot" notation.
Asserts that the property does not match the expected value.
Asserts that the property is of the expected type.
Asserts that all properties are of their expected types.
Asserts that the property contains the expected values.
Ensures that all properties are sorted the same way, recursively.
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Call the given Closure with this instance then return the instance.
Create a new fluent, assertable JSON data instance.
Create a new instance from an array.
Create a new instance from an AssertableJsonString.
Get the instance as an array.
Details
in
Has at line 18
Has
count(string|int $key, int|null $length = null)
Assert that the prop is of the expected size.
in
Has at line 50
Has
countBetween(int|string $min, int|string $max)
Assert that the prop size is between a given minimum and maximum.
abstract $this
has(string $key, null $value = null, Closure|null $scope = null)
Ensure that the given prop exists.
in
Has at line 149
Has
hasAny(array|string $key)
Assert that at least one of the given props exists.
protected mixed
prop(string|null $key = null)
Retrieve a prop within the current scope using "dot" notation.
protected AssertableJson
scope(string $key, Closure $callback)
Instantiate a new "scope" at the path of the given key.
Matching
where(string $key, mixed|Closure $expected)
Asserts that the property matches the expected value.
Matching
whereNot(string $key, mixed|Closure $expected)
Asserts that the property does not match the expected value.
Matching
whereType(string $key, string|array $expected)
Asserts that the property is of the expected type.
$this
whereContains(string $key, mixed $expected)
Asserts that the property contains the expected values.
protected void
ensureSorted(mixed $value)
Ensures that all properties are sorted the same way, recursively.
$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
protected
__construct(array $props, string|null $path = null)
Create a new fluent, assertable JSON data instance.
static AssertableJson
fromAssertableJsonString(AssertableJsonString $json)
Create a new instance from an AssertableJsonString.