FormatterYnToBool
in package
implements
FormatterInterface
Table of Contents
Interfaces
Properties
- $lowercaseCase : bool
- $revert : bool
- $name : string
Methods
- __construct() : mixed
- format() : mixed|null
- Cast y/n to boolean
- setClassBasedOnConfig() : void
- Checks config for this specific formatter, and adjusts class properties based on the config.
- setName() : void
- apply() : bool|null
- Cast y/n to boolean
- revert() : mixed|null
- Cast boolean to y/n
Properties
$lowercaseCase
public
bool
$lowercaseCase
= false
$revert
public
bool
$revert
= false
$name
private
string
$name
= 'ynToBool'
Methods
__construct()
public
__construct([bool $revert = false ][, bool $lowercase = false ]) : mixed
Parameters
- $revert : bool = false
- $lowercase : bool = false
format()
Cast y/n to boolean
public
format(mixed|null $value, array<string|int, mixed> $config[, array<string|int, mixed> $options = [] ]) : mixed|null
Converts 'Y' or 'y' to boolean true. Converts 'N' or 'n' to boolean false. Any other value will produce null.
Parameters
- $value : mixed|null
- $config : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Return values
mixed|nullsetClassBasedOnConfig()
Checks config for this specific formatter, and adjusts class properties based on the config.
public
setClassBasedOnConfig(array<string|int, mixed> $config) : void
Parameters
- $config : array<string|int, mixed>
setName()
public
setName(string $name) : void
Parameters
- $name : string
apply()
Cast y/n to boolean
protected
apply(string|null $value) : bool|null
Converts 'Y' or 'y' to boolean true. Converts 'N' or 'n' to boolean false. Any other value will produce null.
Parameters
- $value : string|null
Return values
bool|nullrevert()
Cast boolean to y/n
protected
revert(mixed|null $value) : mixed|null
Converts boolean true 'y'. Converts boolean false to 'n'. Any other value will produce null.
Parameters
- $value : mixed|null