squirrelphp/twig-php-syntax

View on GitHub
src/Test/StringTest.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Squirrel\TwigPhpSyntax\Test;

use Twig\Compiler;
use Twig\Node\Expression\TestExpression;

/**
 * Checks that a variable is a string.
 *
 *  {{ var is string }}
 */
class StringTest extends TestExpression
{
    public function compile(Compiler $compiler): void
    {
        $compiler
            ->raw('(true === \\is_string(')
            ->subcompile($this->getNode('node'))
            ->raw('))')
        ;
    }
}