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 / URL.php

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

93 lines 2.6 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 use WCPOS\Vendor\Sabberworm\CSS\ShortClassNameProvider;
12 /**
13 * This class represents URLs in CSS. `URL`s always output in `URL("")` notation.
14 */
15 class URL extends PrimitiveValue
16 {
17 use ShortClassNameProvider;
18 /**
19 * @var CSSString
20 */
21 private $url;
22 /**
23 * @param int<1, max>|null $lineNumber
24 */
25 public function __construct(CSSString $url, ?int $lineNumber = null)
26 {
27 parent::__construct($lineNumber);
28 $this->url = $url;
29 }
30 /**
31 * @throws SourceException
32 * @throws UnexpectedEOFException
33 * @throws UnexpectedTokenException
34 *
35 * @internal since V8.8.0
36 */
37 public static function parse(ParserState $parserState) : URL
38 {
39 $anchor = $parserState->anchor();
40 $identifier = '';
41 for ($i = 0; $i < 3; $i++) {
42 $character = $parserState->parseCharacter(\true);
43 if ($character === null) {
44 break;
45 }
46 $identifier .= $character;
47 }
48 $useUrl = $parserState->streql($identifier, 'url');
49 if ($useUrl) {
50 $parserState->consumeWhiteSpace();
51 $parserState->consume('(');
52 } else {
53 $anchor->backtrack();
54 }
55 $parserState->consumeWhiteSpace();
56 $result = new URL(CSSString::parse($parserState), $parserState->currentLine());
57 if ($useUrl) {
58 $parserState->consumeWhiteSpace();
59 $parserState->consume(')');
60 }
61 return $result;
62 }
63 public function setURL(CSSString $url) : void
64 {
65 $this->url = $url;
66 }
67 public function getURL() : CSSString
68 {
69 return $this->url;
70 }
71 /**
72 * @return non-empty-string
73 */
74 public function render(OutputFormat $outputFormat) : string
75 {
76 return "url({$this->url->render($outputFormat)})";
77 }
78 /**
79 * @return array<string, bool|int|float|string|array<mixed>|null>
80 *
81 * @internal
82 */
83 public function getArrayRepresentation() : array
84 {
85 return [
86 'class' => $this->getShortClassName(),
87 // We're using the term "uri" here to match the wording used in the specs:
88 // https://www.w3.org/TR/CSS22/syndata.html#uri
89 'uri' => $this->url->getArrayRepresentation(),
90 ];
91 }
92 }
93