Skip to content

MediaType

Viames Marino edited this page Nov 6, 2026 · 1 revision

Pair framework: MediaType

Pair\Http\MediaType parses HTTP media types and negotiates representations according to RFC 9110.

  • parse(string $value, bool $range = false): array: returns [lowercaseType, parameters, qualityThousandths]; unquotes parameters, validates unique names and q syntax. When range=false, q is an ordinary media parameter.
  • accepts(?string $accept, string $representation = 'application/json'): bool: match the representation's media parameters, apply the most specific matching range before its quality, and accept only a nonzero quality. An absent header permits the representation; an empty header accepts no media type.
  • split(string $value, string $delimiter): array: quoted-aware HTTP list/parameter splitting.

Malformed headers throw InvalidArgumentException; applications translate this to an HTTP error before processing domain data. No application error code or JSON envelope is embedded in the framework parser.

Clone this wiki locally