vendor/symfony/src/Symfony/Component/CssSelector/Token.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     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;
       
    13 
       
    14 /**
       
    15  * Token represents a CSS Selector token.
       
    16  *
       
    17  * This component is a port of the Python lxml library,
       
    18  * which is copyright Infrae and distributed under the BSD license.
       
    19  *
       
    20  * @author Fabien Potencier <fabien@symfony.com>
       
    21  */
       
    22 class Token
       
    23 {
       
    24     private $type;
       
    25     private $value;
       
    26     private $position;
       
    27 
       
    28     /**
       
    29      * Constructor.
       
    30      *
       
    31      * @param string  $type     The type of this token.
       
    32      * @param mixed   $value    The value of this token.
       
    33      * @param integer $position The order of this token.
       
    34      */
       
    35     public function __construct($type, $value, $position)
       
    36     {
       
    37         $this->type = $type;
       
    38         $this->value = $value;
       
    39         $this->position = $position;
       
    40     }
       
    41 
       
    42     /**
       
    43      * Gets a string representation of this token.
       
    44      *
       
    45      * @return string
       
    46      */
       
    47     public function __toString()
       
    48     {
       
    49         return (string) $this->value;
       
    50     }
       
    51 
       
    52     /**
       
    53      * Answers whether this token's type equals to $type.
       
    54      *
       
    55      * @param  string $type The type to test against this token's one.
       
    56      *
       
    57      * @return Boolean
       
    58      */
       
    59     public function isType($type)
       
    60     {
       
    61         return $this->type == $type;
       
    62     }
       
    63 
       
    64     /**
       
    65      * Gets the position of this token.
       
    66      *
       
    67      * @return integer
       
    68      */
       
    69     public function getPosition()
       
    70     {
       
    71         return $this->position;
       
    72     }
       
    73 }