API / Minn\Rest / SchemaValues

SchemaValues final class

Minn\Rest\SchemaValues · public/minn/src/Minn/Rest/SchemaValues.php · 198 lines

The value side of JSON Schema, as the reference applies it: what counts as a boolean, integer, array, or object, the coercions to each, the comparisons and date, colour, and uuid parsers the formats use, and the combining walk anyOf and oneOf share. Schema holds the rules; this holds what they are applied to.

Uses 1

Public

staticisBoolean(mixed $value): bool#

Whether a value reads as a boolean, the strings included.

statictoBoolean(mixed $value): mixed#

The boolean a value reads as.

staticisInteger(mixed $value): bool#

Whether a value is a whole number.

staticisArray(mixed $value): bool#

Whether a value reads as a list, a comma-separated string included.

statictoArray(mixed $value): array#

The list a value reads as.

staticisObject(mixed $value): bool#

Whether a value reads as an object.

statictoObject(mixed $value): array#

The object a value reads as, as an array.

staticbestType(mixed $value, array|string $types): string#

The first of the schema's types, in the order it lists them, that the value reads as (an empty string is a string when that is allowed); '' when none.

staticvaluesEqual(mixed $a, mixed $b): bool#

Whether two values are equal by the reference's loose rules.

staticpatternProperty(string $property, array $args): ?array#

The schema of the patternProperties entry a property name matches, or null.

staticmatchesPattern(string $pattern, string $value): bool#

Whether a value matches a schema pattern, read as the reference reads one: unanchored, # escaped, UTF-8.

statichasUniqueItems(array $items): bool#

Whether no two items are equal once their keys are sorted; types stay apart, so 1 and "1" differ.

staticintersectKeys(array $first, array $second): array#

The first array's entries whose keys the second has too, at every level where both hold an array.

staticstabilize(mixed $value): mixed#

Keys sorted at every level, so two equal structures serialise the same.

staticparseDate(mixed $date, bool $forceUtc = false): int|false#

A timestamp for an RFC3339-shaped date, false otherwise; $forceUtc reads the offset as Z.

staticparseHexColor(mixed $color): mixed#

A hex colour as given, or false.

staticisUuid(mixed $uuid): bool#

Whether a value is a version-4 uuid.

staticlist(mixed $value): array#

A comma- or space-separated string as a list.

@return list<string>

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateobjectOf(mixed $value): ?array#

A value as an object's properties: '' is the empty object, a stdClass its properties, a JsonSerializable what it serializes to; null when it is no object.

@return array<array-key, mixed>|null