FormatterIntToBool
in package
implements
FormatterInterface
Table of Contents
Interfaces
Properties
Methods
- __construct() : mixed
- format() : mixed|null
- Cast integer to boolean
- setClassBasedOnConfig() : void
- Checks config for this specific formatter, and adjusts class properties based on the config.
- apply() : bool|null
- Cast integer to boolean
- revert() : mixed|null
- Cast boolean to int
Properties
$name
private
string
$name
= 'intToBool'
$revert
private
bool
$revert
= false
Methods
__construct()
public
__construct([bool $revert = false ]) : mixed
Parameters
- $revert : bool = false
format()
Cast integer to boolean
public
format(mixed|null $value, array<string|int, mixed> $config[, array<string|int, mixed> $options = [] ]) : mixed|null
Converts number greater than zero to boolean true. Converts number of zero or less to boolean false. Convert empty string to null. Null is passed through unchanged.
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>
apply()
Cast integer to boolean
protected
apply(string|null $value) : bool|null
Converts number greater than zero to boolean true. Converts number of zero or less to boolean false. Convert empty string to null. Null is passed through unchanged.
Parameters
- $value : string|null
Return values
bool|nullrevert()
Cast boolean to int
protected
revert(mixed|null $value) : mixed|null
Converts true'y to 1. Converts false'y to 0. Converts empty string to null. Null is passed through unchanged.
Parameters
- $value : mixed|null