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.
Public
| static | isBoolean(mixed $value): bool# | Whether a value reads as a boolean, the strings included. |
| static | toBoolean(mixed $value): mixed# | The boolean a value reads as. |
| static | isInteger(mixed $value): bool# | Whether a value is a whole number. |
| static | isArray(mixed $value): bool# | Whether a value reads as a list, a comma-separated string included. |
| static | toArray(mixed $value): array# | The list a value reads as. |
| static | isObject(mixed $value): bool# | Whether a value reads as an object. |
| static | toObject(mixed $value): array# | The object a value reads as, as an array. |
| static | bestType(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. |
| static | valuesEqual(mixed $a, mixed $b): bool# | Whether two values are equal by the reference's loose rules. |
| static | patternProperty(string $property, array $args): ?array# | The schema of the patternProperties entry a property name matches, or null. |
| static | matchesPattern(string $pattern, string $value): bool# | Whether a value matches a schema pattern, read as the reference reads one: unanchored, # escaped, UTF-8. |
| static | hasUniqueItems(array $items): bool# | Whether no two items are equal once their keys are sorted; types stay apart, so 1 and "1" differ. |
| static | intersectKeys(array $first, array $second): array# | The first array's entries whose keys the second has too, at every level where both hold an array. |
| static | stabilize(mixed $value): mixed# | Keys sorted at every level, so two equal structures serialise the same. |
| static | parseDate(mixed $date, bool $forceUtc = false): int|false# | A timestamp for an RFC3339-shaped date, false otherwise; $forceUtc reads the offset as Z. |
| static | parseHexColor(mixed $color): mixed# | A hex colour as given, or false. |
| static | isUuid(mixed $uuid): bool# | Whether a value is a version-4 uuid. |
| static | list(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.
| private | objectOf(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 |
Nothing matches.