CssStrategy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A locatorToXpath() 0 9 2
1
<?php
2
3
namespace WebinoDomLib\Locator\Strategy;
4
5
//use WebinoView\Dom\Locator\TransformatorInterface;
6
use Zend\Dom\Document\Query as DomQuery;
7
8
/**
9
 * Class CssStrategy
10
 */
11
class CssStrategy
12
{
13
    /**
14
     * @param string $locator
15
     * @return string
16
     */
17
    public function locatorToXpath($locator)
18
    {
19
        if (0 === strpos($locator, '//')) {
20
            // return early for absolute
21
            return DomQuery::cssToXpath(substr($locator, 2));
22
        }
23
        // dot makes it relative
24
        return '.' . DomQuery::cssToXpath($locator);
25
    }
26
}
27