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   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findFirstInstance() 0 14 2
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