objects
Options
Visitor options the server renders: theme, density, a dismissed banner.
Declared in config as `"options": {"theme": ["default", "dark"]}` - slug keys, the first value the default - so a cookie only ever yields a declared value.
$options
Phlat\Options
7 methods
Show
- any Whether the visitor holds any option cookie.
- chosen Whether the visitor has chosen any declared option, so what they are sent is not the default render everyone else gets.
- get The visitor's value, or the default when unset or no longer declared.
- has Whether config declares an option named $key.
- readKeys The options read through get() so far - what a cached render depends on.
- set Stores the visitor's choice in a cookie; a value config doesn't declare throws.
- values The visitor's values for $keys, without counting them as read: what Cache keys a varied entry on.
Methods
$options->any(): bool
Whether the visitor holds any option cookie.
Returns bool
phlat/src/Options.php:75
$options->chosen(): bool
Whether the visitor has chosen any declared option, so what they are sent is not the default render everyone else gets.
Returns bool
phlat/src/Options.php:33
$options->get(string $key): string
The visitor's value, or the default when unset or no longer declared.
Counts the option as read, so a cached render is kept per value of it (see readKeys()).
Parameters (1)
| $key | string |
Returns string
phlat/src/Options.php:43
$options->has(string $key): bool
Whether config declares an option named $key.
Parameters (1)
| $key | string |
Returns bool
phlat/src/Options.php:27
$options->readKeys(): array
The options read through get() so far - what a cached render depends on.
Returns array
phlat/src/Options.php:62
$options->set(string $key, string $value): void
Stores the visitor's choice in a cookie; a value config doesn't declare throws.
Parameters (2)
| $key | string | |
| $value | string |
phlat/src/Options.php:68
$options->values(array $keys): array
The visitor's values for $keys, without counting them as read: what Cache keys a varied entry on.
Parameters (1)
| $keys | array |
Returns array
phlat/src/Options.php:51