codekandis/types
is a library providing base types, interfaces and classes.
Install the latest version with
$ composer require codekandis/types
The following examples show how to determine the type of a value with the TypeDeterminator
. The parameter $native
specifies if the determined type has to be as PHP's wrapped function gettype()
returns it or if it has to be as strict as type hints.
$value = false;
( new TypeDeterminator() )
->determine( $value );
/**
* boolean
*/
( new TypeDeterminator() )
->determine( $value, true );
/**
* boolean
*/
( new TypeDeterminator() )
->determine( $value, false );
/**
* bool
*/
$value = 42.42;
( new TypeDeterminator() )
->determine( $value );
/**
* double
*/
( new TypeDeterminator() )
->determine( $value, true );
/**
* double
*/
( new TypeDeterminator() )
->determine( $value, false );
/**
* float
*/