4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\CssSelector\Parser;
17 * This component is a port of the Python cssselect library,
18 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
20 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
26 const TYPE_FILE_END = 'eof';
27 const TYPE_DELIMITER = 'delimiter';
28 const TYPE_WHITESPACE = 'whitespace';
29 const TYPE_IDENTIFIER = 'identifier';
30 const TYPE_HASH = 'hash';
31 const TYPE_NUMBER = 'number';
32 const TYPE_STRING = 'string';
40 * @param string $value
41 * @param int $position
43 public function __construct($type, $value, $position)
46 $this->value = $value;
47 $this->position = $position;
53 public function getType()
61 public function getValue()
69 public function getPosition()
71 return $this->position;
77 public function isFileEnd()
79 return self::TYPE_FILE_END === $this->type;
85 public function isDelimiter(array $values = array())
87 if (self::TYPE_DELIMITER !== $this->type) {
95 return \in_array($this->value, $values);
101 public function isWhitespace()
103 return self::TYPE_WHITESPACE === $this->type;
109 public function isIdentifier()
111 return self::TYPE_IDENTIFIER === $this->type;
117 public function isHash()
119 return self::TYPE_HASH === $this->type;
125 public function isNumber()
127 return self::TYPE_NUMBER === $this->type;
133 public function isString()
135 return self::TYPE_STRING === $this->type;
141 public function __toString()
144 return sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position);
147 return sprintf('<%s at %s>', $this->type, $this->position);