Flow PHP

BooleanType implements Type

Read onlyYes
FinalYes
Tags
implements

Interfaces

Type

Methods

assert()  : T
Checks if the value is of the type of given type.
cast()  : T
Takes a value and when necessary casts it to the type of this object.
isValid()  : bool
Checks if the value is of the type of this object.
normalize()  : array<string, string>
toString()  : string
Returns a string representation of the type.

Methods

assert()

Checks if the value is of the type of given type.

public assert(mixed $value) : T

The difference between this method and cast() is that this method does not perform any casting. The difference between this method and isValid() is that this method also returns passed value narrowing it's type. When assert method is used, it will additionally narrow the type of the returned value for static analysis tools.

Parameters
$value : mixed
Return values
T

cast()

Takes a value and when necessary casts it to the type of this object.

public cast(mixed $value) : T

When value is already of the type of this object, it is returned as is. When cast method is used, it will additionally narrow the type of the returned value for static analysis tools.

Parameters
$value : mixed
Return values
T

isValid()

Checks if the value is of the type of this object.

public isValid(mixed $value) : bool

When isValid method is used, it will not narrow the type of the value for static analysis tools.

Parameters
$value : mixed
Return values
bool

normalize()

public normalize() : array<string, string>
Return values
array<string, string>

toString()

Returns a string representation of the type.

public toString() : string
  • string - for type_string()
  • int - for type_int()
  • ?float - for type_optional(type_float())
Return values
string

        
On this page

Search results