public static function type($type, $value, $description = NULL)
{
self::$counter++;
if (!is_object($type) && !is_string($type)) {
throw new \Exception('Type must be a object or a string.');
} elseif ($type === 'list') {
if (!is_array($value) || $value && array_keys($value) !== range(0, count($value) - 1)) {
self::fail(self::describe("%1 should be {$type}", $description), $value);
}
} elseif (in_array($type, ['array', 'bool', 'callable', 'float', 'int', 'integer', 'null', 'object', 'resource', 'scalar', 'string'], TRUE)) {
if (!call_user_func("is_{$type}", $value)) {
self::fail(self::describe(gettype($value) . " should be {$type}", $description));
}
} elseif (!$value instanceof $type) {
$actual = is_object($value) ? get_class($value) : gettype($value);
self::fail(self::describe("{$actual} should be instance of {$type}", $description));
}
}