codekandis / types
`codekandis/types` is a library providing base types, interfaces and classes.
1.0.0
2024-05-16 23:05 UTC
Requires
- php: >=8.3
Requires (Dev)
- codekandis/phpunit: ^5.0.0
- rector/rector: ^1.0.5
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-05-16 23:06:42 UTC
README
codekandis/types
is a library providing base types, interfaces and classes.
Index
Installation
Install the latest version with
$ composer require codekandis/types
How to use
Type determination
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 */