CSSFunction.php
2 years ago
CSSString.php
4 years ago
CalcFunction.php
2 years ago
CalcRuleValueList.php
4 years ago
Color.php
2 years ago
LineName.php
4 years ago
PrimitiveValue.php
4 years ago
RuleValueList.php
4 years ago
Size.php
2 years ago
URL.php
2 years ago
Value.php
2 years ago
ValueList.php
4 years ago
index.php
3 years ago
CSSFunction.php
50 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Sabberworm\CSS\Value; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Sabberworm\CSS\OutputFormat; |
| 5 | use MailPoetVendor\Sabberworm\CSS\Parsing\ParserState; |
| 6 | class CSSFunction extends ValueList |
| 7 | { |
| 8 | protected $sName; |
| 9 | public function __construct($sName, $aArguments, $sSeparator = ',', $iLineNo = 0) |
| 10 | { |
| 11 | if ($aArguments instanceof RuleValueList) { |
| 12 | $sSeparator = $aArguments->getListSeparator(); |
| 13 | $aArguments = $aArguments->getListComponents(); |
| 14 | } |
| 15 | $this->sName = $sName; |
| 16 | $this->iLineNo = $iLineNo; |
| 17 | parent::__construct($aArguments, $sSeparator, $iLineNo); |
| 18 | } |
| 19 | public static function parse(ParserState $oParserState, $bIgnoreCase = \false) |
| 20 | { |
| 21 | $mResult = $oParserState->parseIdentifier($bIgnoreCase); |
| 22 | $oParserState->consume('('); |
| 23 | $aArguments = Value::parseValue($oParserState, ['=', ' ', ',']); |
| 24 | $mResult = new CSSFunction($mResult, $aArguments, ',', $oParserState->currentLine()); |
| 25 | $oParserState->consume(')'); |
| 26 | return $mResult; |
| 27 | } |
| 28 | public function getName() |
| 29 | { |
| 30 | return $this->sName; |
| 31 | } |
| 32 | public function setName($sName) |
| 33 | { |
| 34 | $this->sName = $sName; |
| 35 | } |
| 36 | public function getArguments() |
| 37 | { |
| 38 | return $this->aComponents; |
| 39 | } |
| 40 | public function __toString() |
| 41 | { |
| 42 | return $this->render(new OutputFormat()); |
| 43 | } |
| 44 | public function render(OutputFormat $oOutputFormat) |
| 45 | { |
| 46 | $aArguments = parent::render($oOutputFormat); |
| 47 | return "{$this->sName}({$aArguments})"; |
| 48 | } |
| 49 | } |
| 50 |