dbt/type-checker

A type checker for PHP

2.0.0 2019-08-07 19:29 UTC

This package is auto-updated.

Last update: 2024-12-08 08:26:26 UTC


README

Installation

You can install the package via composer:

composer require dbt/type-checker

Usage

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

Testing

composer test

Etc.

Please see CONTRIBUTING for details. The MIT License (MIT). Please see License File for more information.