Value
Table of Contents
Classes
- CooperAtom
- A CASC atom (CASC.md §6.4) -- `level = info`, `level = :info`.
- CooperBytes
- A CASC byte size (CASC.md §6.9) -- `512MiB`, `10GB`, or
`!bytes("512MiB")` -- as a whole number of bytes, matching the Elixir
original's `{:bytes, count}`.
- CooperDate
- A CASC local date (CASC.md §6.6) -- `1979-05-27` -- with no time or
zone attached, matching Elixir's `Date`. PHP has no date-only type,
and a `DateTimeImmutable` at midnight would invent a time and a zone
the document never stated; `toDateTimeImmutable()` makes that choice
explicit when it is wanted.
- CooperDateTime
- A CASC offset date-time (CASC.md §6.6) -- `1979-05-27T07:32:00Z`,
`...00.120+02:00` -- matching Elixir's `DateTime`: an instant at
microsecond resolution, normalized to UTC, together with how many
fractional digits were written (`$precision`, at most 6).
- CooperDuration
- A CASC duration (CASC.md §6.8) -- `500ms`, `1h30m`, or
`!duration("5m")` -- as a whole number of nanoseconds, the same base
unit the Elixir original's `{:duration, nanoseconds}` uses.
- CooperInteger
- A CASC integer (CASC.md §6.3) too large for PHP's 64-bit `int` --
`12345678901234567890`, or `!int("...")` of one -- kept exactly, as
the Elixir original's arbitrary-precision integers are.
- CooperIPv4
- A parsed IPv4 address, with an optional CIDR prefix (CASC.md §6.7 --
`127.0.0.1` or `127.0.0.1/32`). The constructor validates, and it is
the same validation a bare literal goes through at load time -- an
out-of-range octet or prefix is an error, never a silently accepted
garbage value.
- CooperIPv6
- A parsed IPv6 address, with an optional CIDR prefix (CASC.md §6.7 --
`::1` or `::1/128`). The constructor validates, and it is the same
validation a bare literal goes through at load time.
- CooperLocalDateTime
- A CASC local date-time (CASC.md §6.6) -- `1979-05-27T07:32:00` with
no offset -- matching Elixir's `NaiveDateTime`. An *offset* date-time
(`...Z`, `...+02:00`) is a real instant and loads as a
`CooperDateTime` instead; this one names a wall-clock reading in no
particular zone, which `toDateTimeImmutable()` lets the caller place.
- CooperSecret
- Wraps a secret value (CASC.md §4.3's `*key`-prefixed keys) in the
result `Cooper::loadFile()`/`Cooper::loadString()` return, so it never
leaks by accident: string conversion, `json_encode()`, `var_dump()`,
and `print_r()` all redact regardless of the wrapped value. Reach the
real value deliberately with `reveal()` -- the wrapping is only ever a
display-time concern, never a barrier to the developer's own use of
the value.
- CooperTime
- A CASC local time of day (CASC.md §6.6) -- `07:32:00`, optionally with
fractional seconds -- matching Elixir's `Time`: microsecond resolution,
and the number of fractional digits written (`$precision`, at most 6)
kept so `07:32:00.5` renders back as written rather than as
`07:32:00.500000`.
- CooperTuple
- A CASC tuple (CASC.md §6.11) -- `office_location = (52.5200, 13.4050)`.