Skip to content

Innmind/type

Repository files navigation

type

Build Status codecov Type Coverage

This package allows to describe types as objects to check if a given type can accept a value or if it is compatible with another type.

Installation

composer require innmind/type

Usage

use Innmind\Type\{
    Build,
    Primitive,
};

final class Example
{
    private int $id;
}

$type = Build::fromReflection((new \ReflectionProperty(Example::class, 'id'))->getType());
$type->allows(42); // true
$type->allows('some-uuid'); // false

$type->accepts(Primitive::int()); // true
$type->accepts(Primitive::string()); // false

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages