# TypeInterface

Chevere\Interfaces\Type\TypeInterface

view source

# Description

Describes the component in charge of dynamic type validation.

# Constants

# BOOL

Type string

'bool'

# INT

Type string

'int'

# FLOAT

Type string

'float'

# STRING

Type string

'string'

# ARRAY

Type string

'array'

# OBJECT

Type string

'object'

# CALLABLE

Type string

'callable'

# ITERABLE

Type string

'iterable'

# RESOURCE

Type string

'resource'

# NULL

Type string

'null'

# PRIMITIVE_CLASS_NAME

Type string

'className'

# PRIMITIVE_INTERFACE_NAME

Type string

'interfaceName'

# TYPE_VALIDATORS

Type array

array (
  'array' => 'is_array',
  'bool' => 'is_bool',
  'callable' => 'is_callable',
  'float' => 'is_float',
  'int' => 'is_integer',
  'iterable' => 'is_iterable',
  'null' => 'is_null',
  'object' => 'is_object',
  'resource' => 'is_resource',
  'string' => 'is_string',
  'className' => 'is_object',
  'interfaceName' => 'is_object',
)

# Methods

# __construct()

# Parameters

  1. string $type

THROWS

  • ⚠ Unknown type InvalidArgumentException declared in @throws tag`

# primitive()

Returns the type primitive (array, bool, object, ..., className, interfaceName).

RETURN

string


# typeHinting()

Returns the type hinting.

RETURN

string

It will return either the class name, interface, or the primitive.


# validate()

Returns a boolean indicating if $var validates against the type.

# Parameters

  1. $var

RETURN

bool


# validator()

Returns the validator callable.

RETURN

callable


# isScalar()

Returns a boolean indicating if type is scalar.

RETURN

bool


Last Updated: 1/16/2021, 9:23:54 PM