This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/CssSelector/Token.php
2011-02-05 23:28:22 +01:00

74 lines
1.6 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\CssSelector;
/**
* Token represents a CSS Selector token.
*
* This component is a port of the Python lxml library,
* which is copyright Infrae and distributed under the BSD license.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class Token
{
protected $type;
protected $value;
protected $position;
/**
* Constructor.
*
* @param string $type The type of this token.
* @param mixed $value The value of this token.
* @param int $position The order of this token.
*/
public function __construct($type, $value, $position)
{
$this->type = $type;
$this->value = $value;
$this->position = $position;
}
/**
* Get a string representation of this token.
*
* @return string
*/
public function __toString()
{
return (string) $this->value;
}
/**
* Answer whether this token's type equals to $type.
*
* @param string $type The type to test against this token's one.
*
* @return bool
*/
public function isType($type)
{
return $this->type == $type;
}
/**
* Get the position of this token.
*
* @return int
*/
public function getPosition()
{
return $this->position;
}
}