PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.19
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.19
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / sabberworm / php-css-parser / src / Value / CSSFunction.php

CSSFunction.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.19, at vendor_prefixed/sabberworm/php-css-parser/src/Value/CSSFunction.php

115 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sabberworm\CSS\Value;
5
6 use WCPOS\Vendor\Sabberworm\CSS\OutputFormat;
7 use WCPOS\Vendor\Sabberworm\CSS\Parsing\ParserState;
8 use WCPOS\Vendor\Sabberworm\CSS\Parsing\SourceException;
9 use WCPOS\Vendor\Sabberworm\CSS\Parsing\UnexpectedEOFException;
10 use WCPOS\Vendor\Sabberworm\CSS\Parsing\UnexpectedTokenException;
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 non-empty-string
19 *
20 * @internal since 8.8.0
21 */
22 protected $name;
23 /**
24 * @param non-empty-string $name
25 * @param RuleValueList|array<Value|string> $arguments
26 * @param non-empty-string $separator
27 * @param int<1, max>|null $lineNumber
28 */
29 public function __construct(string $name, $arguments, string $separator = ',', ?int $lineNumber = null)
30 {
31 if ($arguments instanceof RuleValueList) {
32 $separator = $arguments->getListSeparator();
33 $arguments = $arguments->getListComponents();
34 }
35 $this->name = $name;
36 $this->setPosition($lineNumber);
37 // TODO: redundant?
38 parent::__construct($arguments, $separator, $lineNumber);
39 }
40 /**
41 * @throws SourceException
42 * @throws UnexpectedEOFException
43 * @throws UnexpectedTokenException
44 *
45 * @internal since V8.8.0
46 */
47 public static function parse(ParserState $parserState, bool $ignoreCase = \false) : CSSFunction
48 {
49 $name = self::parseName($parserState, $ignoreCase);
50 $parserState->consume('(');
51 $arguments = self::parseArguments($parserState);
52 $result = new CSSFunction($name, $arguments, ',', $parserState->currentLine());
53 $parserState->consume(')');
54 return $result;
55 }
56 /**
57 * @throws SourceException
58 * @throws UnexpectedEOFException
59 * @throws UnexpectedTokenException
60 */
61 private static function parseName(ParserState $parserState, bool $ignoreCase = \false) : string
62 {
63 return $parserState->parseIdentifier($ignoreCase);
64 }
65 /**
66 * @return Value|string
67 *
68 * @throws SourceException
69 * @throws UnexpectedEOFException
70 * @throws UnexpectedTokenException
71 */
72 private static function parseArguments(ParserState $parserState)
73 {
74 return Value::parseValue($parserState, ['=', ' ', ',']);
75 }
76 /**
77 * @return non-empty-string
78 */
79 public function getName() : string
80 {
81 return $this->name;
82 }
83 /**
84 * @param non-empty-string $name
85 */
86 public function setName(string $name) : void
87 {
88 $this->name = $name;
89 }
90 /**
91 * @return array<Value|string>
92 */
93 public function getArguments() : array
94 {
95 return $this->components;
96 }
97 /**
98 * @return non-empty-string
99 */
100 public function render(OutputFormat $outputFormat) : string
101 {
102 $arguments = parent::render($outputFormat);
103 return "{$this->name}({$arguments})";
104 }
105 /**
106 * @return array<string, bool|int|float|string|array<mixed>|null>
107 *
108 * @internal
109 */
110 public function getArrayRepresentation() : array
111 {
112 return \array_merge(['class' => 'placeholder', 'name' => $this->name], parent::getArrayRepresentation());
113 }
114 }
115