PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.13
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.13
4.1.20 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 All 174 releases
searchpro / BerqWP / vendor-prefixed / vendor / symfony / css-selector / Parser / Token.php

Token.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.1.13, at BerqWP/vendor-prefixed/vendor/symfony/css-selector/Parser/Token.php

95 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace BerqWP_Deps\Symfony\Component\CssSelector\Parser;
12
13 /**
14 * CSS selector token.
15 *
16 * This component is a port of the Python cssselect library,
17 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
18 *
19 * @author Jean-François Simon <[email protected]>
20 *
21 * @internal
22 */
23 class Token
24 {
25 public const TYPE_FILE_END = 'eof';
26 public const TYPE_DELIMITER = 'delimiter';
27 public const TYPE_WHITESPACE = 'whitespace';
28 public const TYPE_IDENTIFIER = 'identifier';
29 public const TYPE_HASH = 'hash';
30 public const TYPE_NUMBER = 'number';
31 public const TYPE_STRING = 'string';
32 private $type;
33 private $value;
34 private $position;
35 public function __construct(?string $type, ?string $value, ?int $position)
36 {
37 $this->type = $type;
38 $this->value = $value;
39 $this->position = $position;
40 }
41 public function getType(): ?int
42 {
43 return $this->type;
44 }
45 public function getValue(): ?string
46 {
47 return $this->value;
48 }
49 public function getPosition(): ?int
50 {
51 return $this->position;
52 }
53 public function isFileEnd(): bool
54 {
55 return self::TYPE_FILE_END === $this->type;
56 }
57 public function isDelimiter(array $values = []): bool
58 {
59 if (self::TYPE_DELIMITER !== $this->type) {
60 return \false;
61 }
62 if (empty($values)) {
63 return \true;
64 }
65 return \in_array($this->value, $values);
66 }
67 public function isWhitespace(): bool
68 {
69 return self::TYPE_WHITESPACE === $this->type;
70 }
71 public function isIdentifier(): bool
72 {
73 return self::TYPE_IDENTIFIER === $this->type;
74 }
75 public function isHash(): bool
76 {
77 return self::TYPE_HASH === $this->type;
78 }
79 public function isNumber(): bool
80 {
81 return self::TYPE_NUMBER === $this->type;
82 }
83 public function isString(): bool
84 {
85 return self::TYPE_STRING === $this->type;
86 }
87 public function __toString(): string
88 {
89 if ($this->value) {
90 return sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position);
91 }
92 return sprintf('<%s at %s>', $this->type, $this->position);
93 }
94 }
95