class IsType extends Comparator (View source)

Check if the value is of a given type. Supports all scalar types, objects, arrays, callables, classes, interfaces and traits.

Supports the following types:

  • int
  • float
  • bool
  • string
  • scalar
  • numeric
  • null
  • array
  • object
  • resource
  • callable
  • iterable
  • class (e.g. MyClass::class)
  • interface (e.g. MyInterface::class)
  • trait (e.g. MyTrait::class)

Methods

__construct(string $type)

No description

bool
__invoke(mixed $value)

Compare the input value against the comparator.

static IsType
array()

No description

static IsType
bool()

No description

static IsType
callable()

No description

bool
check(mixed $value)

Compare the input value against the comparator.

static IsType
class(string $class)

No description

static IsType
float()

No description

static IsType
int()

No description

static IsType
interface(string $interface)

No description

static IsType
iterable()

No description

static IsType
make(string $type)

No description

static IsType
null()

No description

static IsType
numeric()

No description

static IsType
object()

No description

static IsType
resource()

No description

static IsType
scalar()

No description

static IsType
string()

No description

static IsType
trait(string $trait)

No description

Details

__construct(string $type)

No description

Parameters

string $type

The type to check for

Exceptions

InvalidArgumentException

final bool __invoke(mixed $value)

Compare the input value against the comparator.

Parameters

mixed $value

Return Value

bool

static IsType array()

No description

Return Value

IsType

static IsType bool()

No description

Return Value

IsType

static IsType callable()

No description

Return Value

IsType

bool check(mixed $value)

Compare the input value against the comparator.

Parameters

mixed $value

Return Value

bool

static IsType class(string $class)

No description

Parameters

string $class

Return Value

IsType

static IsType float()

No description

Return Value

IsType

static IsType int()

No description

Return Value

IsType

static IsType interface(string $interface)

No description

Parameters

string $interface

Return Value

IsType

static IsType iterable()

No description

Return Value

IsType

static IsType make(string $type)

No description

Parameters

string $type

The type to check for

Return Value

IsType

Exceptions

InvalidArgumentException

static IsType null()

No description

Return Value

IsType

static IsType numeric()

No description

Return Value

IsType

static IsType object()

No description

Return Value

IsType

static IsType resource()

No description

Return Value

IsType

static IsType scalar()

No description

Return Value

IsType

static IsType string()

No description

Return Value

IsType

static IsType trait(string $trait)

No description

Parameters

string $trait

Return Value

IsType