Skip to content
docsv0.2.0

ManifestData

Internal helpers that turn a decoded manifest array into validated, strictly-typed value-object fields. Every failure surfaces as an {@see InvalidManifestException}; callers pass the value-object `$type` (and, where known, the record `$subject`) so a failure names the exact offending entry. Shared by the manifest value objects so version and required-field validation is defined once.

ManifestData::requireString()

public static function requireString(array $data, string $key, string $type, ?string $subject = null): string

Extract a required, non-empty string field.

Parameters

Parameters of requireString()
NameTypeDescription
$dataarray<string, mixed>
$keystring
$typestring
$subject?string

Throws

InvalidManifestException When the field is absent or empty.

ManifestData::requireSemver()

public static function requireSemver(array $data, string $key, string $type, ?string $subject = null): string

Extract a required field and assert it parses as a semantic version. Uses composer/semver's parser, which is lenient enough for two-part contract versions (`0.1`) and calendar host versions (`2026.07`) yet still rejects non-versions.

Parameters

Parameters of requireSemver()
NameTypeDescription
$dataarray<string, mixed>
$keystring
$typestring
$subject?string

Throws

InvalidManifestException When the field is absent or not a valid version.

ManifestData::requireArray()

public static function requireArray(array $data, string $key, string $type, ?string $subject = null): array

Extract a required array field (also used for nested value objects such as the host profile).

Parameters

Parameters of requireArray()
NameTypeDescription
$dataarray<string, mixed>
$keystring
$typestring
$subject?string

Throws

InvalidManifestException When the field is absent or not an array.

ManifestData::optionalArray()

public static function optionalArray(array $data, string $key): array

Extract an optional array field, defaulting to an empty array.

Parameters

Parameters of optionalArray()
NameTypeDescription
$dataarray<string, mixed>
$keystring

ManifestData::optionalString()

public static function optionalString(array $data, string $key): ?string

Extract an optional non-empty string field, defaulting to null.

Parameters

Parameters of optionalString()
NameTypeDescription
$dataarray<string, mixed>
$keystring

ManifestData::optionalIsoDate()

public static function optionalIsoDate(array $data, string $key, string $type, ?string $subject = null): ?string

Extract an optional ISO-8601 date/datetime field, defaulting to null. Present-but-unparseable values throw so an expiry can be trusted. Relative expressions ("now", "tomorrow", "+1 day") are rejected as non-ISO on purpose: they would make parsing read the wall clock and break the resolver's purity — the clock is data the caller supplies, never an ambient read.

Parameters

Parameters of optionalIsoDate()
NameTypeDescription
$dataarray<string, mixed>
$keystring
$typestring
$subject?string

Throws

InvalidManifestException When the field is present but not a valid ISO-8601 date.

ManifestData::isIsoDate()

public static function isIsoDate(string $value): bool

Whether a string is an ISO-8601 date or datetime: year-first shape (so relative expressions are rejected) that the datetime parser also accepts.

Parameters

Parameters of isIsoDate()
NameTypeDescription
$valuestring

ManifestData::stringList()

public static function stringList(array $data, string $key): array

Coerce an optional field into a list of non-empty strings, dropping non-scalar entries.

Parameters

Parameters of stringList()
NameTypeDescription
$dataarray<string, mixed>
$keystring

ManifestData::recordList()

public static function recordList(array $data, string $key): array

Coerce an optional field into a list of associative records, dropping non-array entries. Each record is ready to hand to another value object's `fromArray()`.

Parameters

Parameters of recordList()
NameTypeDescription
$dataarray<string, mixed>
$keystring