PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / vendor / symfony / css-selector / Parser / Token.php

Token.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at vendor/symfony/css-selector/Parser/Token.php

114 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 <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\CssSelector\Parser;
13
14 /**
15 * CSS selector token.
16 *
17 * This component is a port of the Python cssselect library,
18 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
19 *
20 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
21 *
22 * @internal
23 */
24 class Token
25 {
26 public const TYPE_FILE_END = 'eof';
27 public const TYPE_DELIMITER = 'delimiter';
28 public const TYPE_WHITESPACE = 'whitespace';
29 public const TYPE_IDENTIFIER = 'identifier';
30 public const TYPE_HASH = 'hash';
31 public const TYPE_NUMBER = 'number';
32 public const TYPE_STRING = 'string';
33
34 /**
35 * @param self::TYPE_*|null $type
36 */
37 public function __construct(
38 private ?string $type,
39 private ?string $value,
40 private ?int $position,
41 ) {
42 }
43
44 /**
45 * @return self::TYPE_*|null
46 */
47 public function getType(): ?string
48 {
49 return $this->type;
50 }
51
52 public function getValue(): ?string
53 {
54 return $this->value;
55 }
56
57 public function getPosition(): ?int
58 {
59 return $this->position;
60 }
61
62 public function isFileEnd(): bool
63 {
64 return self::TYPE_FILE_END === $this->type;
65 }
66
67 public function isDelimiter(array $values = []): bool
68 {
69 if (self::TYPE_DELIMITER !== $this->type) {
70 return false;
71 }
72
73 if (!$values) {
74 return true;
75 }
76
77 return \in_array($this->value, $values, true);
78 }
79
80 public function isWhitespace(): bool
81 {
82 return self::TYPE_WHITESPACE === $this->type;
83 }
84
85 public function isIdentifier(): bool
86 {
87 return self::TYPE_IDENTIFIER === $this->type;
88 }
89
90 public function isHash(): bool
91 {
92 return self::TYPE_HASH === $this->type;
93 }
94
95 public function isNumber(): bool
96 {
97 return self::TYPE_NUMBER === $this->type;
98 }
99
100 public function isString(): bool
101 {
102 return self::TYPE_STRING === $this->type;
103 }
104
105 public function __toString(): string
106 {
107 if ($this->value) {
108 return \sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position);
109 }
110
111 return \sprintf('<%s at %s>', $this->type, $this->position);
112 }
113 }
114