PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / vendor / sabberworm / php-css-parser / src / Value / CSSFunction.php

CSSFunction.php in Yatra – Travel Booking & Tour Operator Software trunk, at vendor/sabberworm/php-css-parser/src/Value/CSSFunction.php

110 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sabberworm\CSS\Value;
4
5 use Sabberworm\CSS\OutputFormat;
6 use Sabberworm\CSS\Parsing\ParserState;
7 use Sabberworm\CSS\Parsing\SourceException;
8 use Sabberworm\CSS\Parsing\UnexpectedEOFException;
9 use Sabberworm\CSS\Parsing\UnexpectedTokenException;
10
11 /**
12 * A `CSSFunction` represents a special kind of value that also contains a function name and where the values are the
13 * function’s arguments. It also handles equals-sign-separated argument lists like `filter: alpha(opacity=90);`.
14 */
15 class CSSFunction extends ValueList
16 {
17 /**
18 * @var string
19 *
20 * @internal since 8.8.0
21 */
22 protected $sName;
23
24 /**
25 * @param string $sName
26 * @param RuleValueList|array<int, RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string> $aArguments
27 * @param string $sSeparator
28 * @param int $iLineNo
29 */
30 public function __construct($sName, $aArguments, $sSeparator = ',', $iLineNo = 0)
31 {
32 if ($aArguments instanceof RuleValueList) {
33 $sSeparator = $aArguments->getListSeparator();
34 $aArguments = $aArguments->getListComponents();
35 }
36 $this->sName = $sName;
37 $this->setPosition($iLineNo); // TODO: redundant?
38 parent::__construct($aArguments, $sSeparator, $iLineNo);
39 }
40
41 /**
42 * @param ParserState $oParserState
43 * @param bool $bIgnoreCase
44 *
45 * @return CSSFunction
46 *
47 * @throws SourceException
48 * @throws UnexpectedEOFException
49 * @throws UnexpectedTokenException
50 *
51 * @internal since V8.8.0
52 */
53 public static function parse(ParserState $oParserState, $bIgnoreCase = false)
54 {
55 $mResult = $oParserState->parseIdentifier($bIgnoreCase);
56 $oParserState->consume('(');
57 $aArguments = Value::parseValue($oParserState, ['=', ' ', ',']);
58 $mResult = new CSSFunction($mResult, $aArguments, ',', $oParserState->currentLine());
59 $oParserState->consume(')');
60 return $mResult;
61 }
62
63 /**
64 * @return string
65 */
66 public function getName()
67 {
68 return $this->sName;
69 }
70
71 /**
72 * @param string $sName
73 *
74 * @return void
75 */
76 public function setName($sName)
77 {
78 $this->sName = $sName;
79 }
80
81 /**
82 * @return array<int, RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string>
83 */
84 public function getArguments()
85 {
86 return $this->aComponents;
87 }
88
89 /**
90 * @return string
91 *
92 * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
93 */
94 public function __toString()
95 {
96 return $this->render(new OutputFormat());
97 }
98
99 /**
100 * @param OutputFormat|null $oOutputFormat
101 *
102 * @return string
103 */
104 public function render($oOutputFormat)
105 {
106 $aArguments = parent::render($oOutputFormat);
107 return "{$this->sName}({$aArguments})";
108 }
109 }
110