GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PurgeHtmlCrawler::findFirstInstance()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 3
nop 1
1
<?php
2
3
4
5
namespace Katten\Purge;
6
7
8
9
use Symfony\Component\DomCrawler\Crawler;
10
use Symfony\Component\CssSelector\CssSelector;
11
use Symfony\Component\CssSelector\Exception\ParseException;
12
13
14
15
class PurgeHtmlCrawler extends Crawler {
16
17
18
    /**
19
     * Modify the xPath query provided by CssSelector to 
20
     * find the first instance of a given element, this reduces
21
     * search times compared to filter which returns a whole collection
22
     * 
23
     * @param string $selector
24
     *      A css selector
25
     * 
26
     * @return Crawler
27
     *      The first instance of selected element
28
     */ 
29
    public function findFirstInstance($selector) {
30
31
        try {
32
    
33
            $xPath = CssSelector::toXPath($selector);
34
            $xPath = '(' . $xPath . ')[1]';
35
        
36
            return $this->filterXPath($xPath);
37
        }
38
        catch (ParseException $e) {
39
            
40
            throw new ParseException("{$e->getMessage()} Invalid Selector: $selector");
41
        }
42
    }
43
44
}
45