dbt/type-checker

2.0.0 2019-08-07 19:29 UTC

This package is auto-updated.

Last update: 2024-09-08 07:58:57 UTC


README

安装

您可以通过 composer 安装此包

composer require dbt/type-checker

用法

检查标量类型

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

和可调用对象

Type::of('strstr')->is('callable'); // true
Type::of('strstr')->is('string'); // also true

和类

Type::of($myClass)->is(MyClass::class);
Type::of($myClass)->is(MyInterface::class);

失败时抛出异常

Type::of('my string')->mustBe('float'); // Throws WrongType exception

测试

composer test

等。

有关详细信息,请参阅 CONTRIBUTING。MIT 许可证 (MIT)。更多信息请参阅 许可证文件