vendor/symfony/src/Symfony/Component/CssSelector/Node/OrNode.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\Node;
       
    13 
       
    14 use Symfony\Component\CssSelector\XPathExprOr;
       
    15 
       
    16 /**
       
    17  * OrNode represents a "Or" node.
       
    18  *
       
    19  * This component is a port of the Python lxml library,
       
    20  * which is copyright Infrae and distributed under the BSD license.
       
    21  *
       
    22  * @author Fabien Potencier <fabien@symfony.com>
       
    23  */
       
    24 class OrNode implements NodeInterface
       
    25 {
       
    26     protected $items;
       
    27 
       
    28     /**
       
    29      * Constructor.
       
    30      *
       
    31      * @param array $items An array of NodeInterface objects
       
    32      */
       
    33     public function __construct($items)
       
    34     {
       
    35         $this->items = $items;
       
    36     }
       
    37 
       
    38     /**
       
    39      * {@inheritDoc}
       
    40      */
       
    41     public function __toString()
       
    42     {
       
    43         return sprintf('%s(%s)', __CLASS__, $this->items);
       
    44     }
       
    45 
       
    46     /**
       
    47      * {@inheritDoc}
       
    48      */
       
    49     public function toXpath()
       
    50     {
       
    51         $paths = array();
       
    52         foreach ($this->items as $item) {
       
    53             $paths[] = $item->toXpath();
       
    54         }
       
    55 
       
    56         return new XPathExprOr($paths);
       
    57     }
       
    58 }