SassLiteral::assertType PHP Method

assertType() public static method

Asserts that the literal is the expected type
public static assertType ( $literal, string $type )
$type string expected type
    public static function assertType($literal, $type)
    {
        if (!$literal instanceof $type) {
            throw new SassScriptFunctionException(($literal instanceof SassLiteral ? get_class($literal) : 'literal') . ' must be a ' . $type, SassScriptParser::$context->node);
        }
    }

Usage Example

 /**
  * Inspects the type of the argument, returning it as an unquoted string.
  * @param SassLiteral The object to inspect
  * @return new SassString The type of object
  * @throws SassScriptFunctionException If $obj is not an instance of a
  * SassLiteral
  */
 public static function type_of($obj)
 {
     SassLiteral::assertType($obj, SassLiteral);
     return new SassString($obj->typeOf);
 }
All Usage Examples Of SassLiteral::assertType