You can install the package via composer:
composer require dbt/type-checker
Check scalar types:
Type::of('some-string')->is('string'); // true
// but you don't need to use the factory function if you don't want to:
$type = new Type(12);
$type->is('float'); // false
And callables:
Type::of('strstr')->is('callable'); // true
Type::of('strstr')->is('string'); // also true
And classes:
Type::of($myClass)->is(MyClass::class);
Type::of($myClass)->is(MyInterface::class);
Throw on failure:
Type::of('my string')->mustBe('float'); // Throws WrongType exception
composer test
Please see CONTRIBUTING for details. The MIT License (MIT). Please see License File for more information.