cloudformation-plus-plus: cfn template preprocessor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

58 lines
1005 B

<?php
declare(strict_types=1);
namespace App\Engine\Cfnpp\Expression;
class TokenOperator extends Token
{
public const OPERATORS = [
'eq',
'gt',
'gte',
'lt',
'lte',
'neq',
'and',
'or'
];
protected $operator;
public function __construct($operator)
{
$this->operator = $operator;
}
public function getOperator()
{
return $this->operator;
}
public static function isToken(string $stream): bool
{
foreach (static::OPERATORS as $operator)
{
if (strlen($stream) > strlen($operator) &&
substr($stream, 0, strlen($operator)) == $operator)
{
return true;
}
}
return false;
}
public static function getToken(string &$stream): Token
{
foreach (static::OPERATORS as $operator)
{
if (strlen($stream) > strlen($operator) &&
substr($stream, 0, strlen($operator)) == $operator)
{
$operator = substr($stream, 0, strlen($operator));
$stream = substr($stream, strlen($operator));
return new TokenOperator($operator);
}
}
}
}