src/Assert.php
public static function assertTypeOf(string $type, $actual, string $message = '')
    {
        self::$count += 1;

        switch (strtolower($type)) {
            case 'array':
                if (is_array($actual)) {
                    return;
                }
                break;

            case 'resource':
                if (is_resource($actual)) {
                    return;
                }
                break;

            case 'object':
                if (is_object($actual)) {
                    return;
                }
                break;

            case 'int':
            case 'integer':
            case 'long':
                if (is_int($actual)) {
                    return;
                }
                break;

            case 'double':
            case 'float':
                if (is_float($actual)) {
                    return;
                }
                break;

            case 'numeric':
                if (is_numeric($actual)) {
                    return;
                }
                break;

            case 'bool':
            case 'boolean':
                if (is_bool($actual)) {
                    return;
                }
                break;

            case 'callable':
                if (is_callable($actual)) {
                    return;
                }
                break;

            case 'null':
                if (is_null($actual)) {
                    return;
                }
                break;

            case 'string':
                if (is_string($actual)) {
                    return;
                }
                break;

            default:
                throw new AssertionLogicError(sprintf('No assertion defined for type %s', $type));
        }

        if (!$message) {
            $message = sprintf(
                'Failed asserting that %s is of type %s',
                static::getType($actual),
                $type
            );
        }
        throw new AssertionError($message);
    }
public static function assertTypeOf(string $type, $actual, string $message = '')
    {
        self::$count += 1;

        switch (strtolower($type)) {
            case 'array':
                if (is_array($actual)) {
                    return;
                }
                break;

            case 'resource':
                if (is_resource($actual)) {
                    return;
                }
                break;

            case 'object':
                if (is_object($actual)) {
                    return;
                }
                break;

            case 'int':
            case 'integer':
            case 'long':
                if (is_int($actual)) {
                    return;
                }
                break;

            case 'double':
            case 'float':
                if (is_float($actual)) {
                    return;
                }
                break;

            case 'numeric':
                if (is_numeric($actual)) {
                    return;
                }
                break;

            case 'bool':
            case 'boolean':
                if (is_bool($actual)) {
                    return;
                }
                break;

            case 'callable':
                if (is_callable($actual)) {
                    return;
                }
                break;

            case 'null':
                if (is_null($actual)) {
                    return;
                }
                break;

            case 'string':
                if (is_string($actual)) {
                    return;
                }
                break;

            default:
                throw new AssertionLogicError(sprintf('No assertion defined for type %s', $type));
        }

        if (!$message) {
            $message = sprintf(
                'Failed asserting that %s is of type %s',
                static::getType($actual),
                $type
            );
        }
        throw new AssertionError($message);
    }
public static function assertTypeOf ( string $ type , $ actual , string $ message = '' ) { self :: $ count += 1 ; switch ( strtolower ( $ type ) ) { case 'array' : if ( is_array ( $ actual ) ) { return ; } break ; case 'resource' : if ( is_resource ( $ actual ) ) { return ; } break ; case 'object' : if ( is_object ( $ actual ) ) { return ; } break ; case 'int' : case 'integer' : case 'long' : if ( is_int ( $ actual ) ) { return ; } break ; case 'double' : case 'float' : if ( is_float ( $ actual ) ) { return ; } break ; case 'numeric' : if ( is_numeric ( $ actual ) ) { return ; } break ; case 'bool' : case 'boolean' : if ( is_bool ( $ actual ) ) { return ; } break ; case 'callable' : if ( is_callable ( $ actual ) ) { return ; } break ; case 'null' : if ( is_null ( $ actual ) ) { return ; } break ; case 'string' : if ( is_string ( $ actual ) ) { return ; } break ; default : throw new AssertionLogicError ( sprintf ( 'No assertion defined for type %s' , $ type ) ) ; } if ( ! $ message ) { $ message = sprintf ( 'Failed asserting that %s is of type %s' , static :: getType ( $ actual ) , $ type ) ; } throw new AssertionError ( $ message ) ; }
Test if the given value is an instance of the given type

@example
\Cundd\TestFlight\Assert::assertTypeOf('array', []);
\Cundd\TestFlight\Assert::assertTypeOf('Array', []);
\Cundd\TestFlight\Assert::assertTypeOf('object', new stdClass());
\Cundd\TestFlight\Assert::assertTypeOf('int', 0);
\Cundd\TestFlight\Assert::assertTypeOf('integer', 1);
\Cundd\TestFlight\Assert::assertTypeOf('long', 1);
\Cundd\TestFlight\Assert::assertTypeOf('float', 0.1);
\Cundd\TestFlight\Assert::assertTypeOf('double', 0.1);
\Cundd\TestFlight\Assert::assertTypeOf('numeric', 1);
\Cundd\TestFlight\Assert::assertTypeOf('numeric', 0.1);
\Cundd\TestFlight\Assert::assertTypeOf('numeric', '1');
\Cundd\TestFlight\Assert::assertTypeOf('numeric', '0.1');
\Cundd\TestFlight\Assert::assertTypeOf('null', null);
\Cundd\TestFlight\Assert::assertTypeOf('string', 'a string');
\Cundd\TestFlight\Assert::assertTypeOf('string', 'null');
\Cundd\TestFlight\Assert::assertTypeOf('resource', fopen('php://temp', 'a+'));

@param string $type
@param mixed  $actual
@param string $message
@throws AssertionError
Test if the given value is an instance of the given type