Security update for permissions_by_term
[yaffs-website] / vendor / behat / mink / src / Selector / CssSelector.php
1 <?php
2
3 /*
4  * This file is part of the Mink package.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Mink\Selector;
12
13 use Symfony\Component\CssSelector\CssSelector as CSS;
14 use Symfony\Component\CssSelector\CssSelectorConverter;
15
16 /**
17  * CSS selector engine. Transforms CSS to XPath.
18  *
19  * @author Konstantin Kudryashov <ever.zet@gmail.com>
20  */
21 class CssSelector implements SelectorInterface
22 {
23     /**
24      * Translates CSS into XPath.
25      *
26      * @param string|array $locator current selector locator
27      *
28      * @return string
29      */
30     public function translateToXPath($locator)
31     {
32         if (!is_string($locator)) {
33             throw new \InvalidArgumentException('The CssSelector expects to get a string as locator');
34         }
35
36         // Symfony 2.8+ API
37         if (class_exists('Symfony\Component\CssSelector\CssSelectorConverter')) {
38             $converter = new CssSelectorConverter();
39
40             return $converter->toXPath($locator);
41         }
42
43         // old static API for Symfony 2.7 and older
44         return CSS::toXPath($locator);
45     }
46 }