innmind / type
1.2.0
2024-02-17 08:56 UTC
Requires
- php: ~8.2
Requires (Dev)
- innmind/black-box: ~5.1
- innmind/coding-standard: ~2.0
- vimeo/psalm: ~5.13
This package is auto-updated.
Last update: 2024-10-17 10:23:07 UTC
README
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