__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Sabberworm\CSS\Value;
use Sabberworm\CSS\Parsing\ParserState;
use Sabberworm\CSS\Parsing\UnexpectedEOFException;
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
class CalcFunction extends CSSFunction
{
/**
* @var int
*/
const T_OPERAND = 1;
/**
* @var int
*/
const T_OPERATOR = 2;
/**
* @return CalcFunction
*
* @throws UnexpectedTokenException
* @throws UnexpectedEOFException
*/
public static function parse(ParserState $oParserState)
{
$aOperators = ['+', '-', '*', '/'];
$sFunction = trim($oParserState->consumeUntil('(', false, true));
$oCalcList = new CalcRuleValueList($oParserState->currentLine());
$oList = new RuleValueList(',', $oParserState->currentLine());
$iNestingLevel = 0;
$iLastComponentType = null;
while (!$oParserState->comes(')') || $iNestingLevel > 0) {
$oParserState->consumeWhiteSpace();
if ($oParserState->comes('(')) {
$iNestingLevel++;
$oCalcList->addListComponent($oParserState->consume(1));
$oParserState->consumeWhiteSpace();
continue;
} elseif ($oParserState->comes(')')) {
$iNestingLevel--;
$oCalcList->addListComponent($oParserState->consume(1));
$oParserState->consumeWhiteSpace();
continue;
}
if ($iLastComponentType != CalcFunction::T_OPERAND) {
$oVal = Value::parsePrimitiveValue($oParserState);
$oCalcList->addListComponent($oVal);
$iLastComponentType = CalcFunction::T_OPERAND;
} else {
if (in_array($oParserState->peek(), $aOperators)) {
if (($oParserState->comes('-') || $oParserState->comes('+'))) {
if (
$oParserState->peek(1, -1) != ' '
|| !($oParserState->comes('- ')
|| $oParserState->comes('+ '))
) {
throw new UnexpectedTokenException(
" {$oParserState->peek()} ",
$oParserState->peek(1, -1) . $oParserState->peek(2),
'literal',
$oParserState->currentLine()
);
}
}
$oCalcList->addListComponent($oParserState->consume(1));
$iLastComponentType = CalcFunction::T_OPERATOR;
} else {
throw new UnexpectedTokenException(
sprintf(
'Next token was expected to be an operand of type %s. Instead "%s" was found.',
implode(', ', $aOperators),
$oVal
),
'',
'custom',
$oParserState->currentLine()
);
}
}
$oParserState->consumeWhiteSpace();
}
$oList->addListComponent($oCalcList);
$oParserState->consume(')');
return new CalcFunction($sFunction, $oList, ',', $oParserState->currentLine());
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| CSSFunction.php | File | 1.55 KB | 0777 |
|
| CSSString.php | File | 2.66 KB | 0777 |
|
| CalcFunction.php | File | 3.33 KB | 0777 |
|
| CalcRuleValueList.php | File | 441 B | 0777 |
|
| Color.php | File | 5.65 KB | 0777 |
|
| LineName.php | File | 1.76 KB | 0777 |
|
| PrimitiveValue.php | File | 228 B | 0777 |
|
| RuleValueList.php | File | 291 B | 0777 |
|
| Size.php | File | 5.25 KB | 0777 |
|
| URL.php | File | 1.76 KB | 0777 |
|
| Value.php | File | 7.03 KB | 0777 |
|
| ValueList.php | File | 2.34 KB | 0777 |
|