OpenSiteExplorer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 1
dl 0
loc 50
ccs 33
cts 33
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPageMetrics() 0 47 2
1
<?php
2
namespace SEOstats\Services;
3
4
/**
5
 * SEOstats extension for SEOmoz' OpenSiteExplorer data.
6
 *
7
 * @package    SEOstats
8
 * @author     Stephan Schmitz <[email protected]>
9
 * @copyright  Copyright (c) 2010 - present Stephan Schmitz
10
 * @license    http://eyecatchup.mit-license.org/  MIT License
11
 * @updated    2013/12/08
12
 */
13
14
use SEOstats\SEOstats as SEOstats;
15
use SEOstats\Config as Config;
16
17
class OpenSiteExplorer extends SEOstats
18
{
19 2
    public static function getPageMetrics($url = false)
20
    {
21 2
        $url     = parent::getUrl($url);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getUrl() instead of getPageMetrics()). Are you sure this is correct? If so, you might want to change this to $this->getUrl().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
22 2
        $dataUrl = sprintf(Config\Services::OPENSITEEXPLORER_URL, 'links', '1', urlencode($url));
23
24 2
        $html  = static::_getPage($dataUrl);
25 2
        $doc   = parent::_getDOMDocument($html);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (_getDOMDocument() instead of getPageMetrics()). Are you sure this is correct? If so, you might want to change this to $this->_getDOMDocument().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
26 2
        $xpath = parent::_getDOMXPath(@$doc);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (_getDOMXPath() instead of getPageMetrics()). Are you sure this is correct? If so, you might want to change this to $this->_getDOMXPath().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
27
28 2
        $tooltipNodes = @$xpath->query('//*[@class="tooltip"]');
29 2
        $resultNodes  = @$xpath->query('//*[@class="has-tooltip"]');
30 2
        $resultNodes2 = @$xpath->query('//*[@class="has-tooltip"]/span[1]');
31 2
        $unitNodes    = @$xpath->query('//*[@class="has-tooltip"]/span[2]');
32
33 2
        if (0 < $resultNodes->length) {
34
            return (object) array(
35
                'domainAuthority' => (object) array(
36 1
                    'result' => intval($resultNodes2->item(0)->nodeValue),
37 1
                    'unit'   => trim(strip_tags($unitNodes->item(0)->nodeValue)),
38 1
                    'descr'  => trim(strip_tags($tooltipNodes->item(0)->nodeValue)),
39 1
                ),
40
                'pageAuthority' => (object) array(
41 1
                    'result' => intval($resultNodes2->item(1)->nodeValue),
42 1
                    'unit'   => trim(strip_tags($unitNodes->item(1)->nodeValue)),
43 1
                    'descr'  => trim(strip_tags($tooltipNodes->item(1)->nodeValue)),
44 1
                ),
45
                'justDiscovered' => (object) array(
46 1
                    'result' => intval(str_replace(',', '', strip_tags($resultNodes->item(2)->nodeValue))),
47 1
                    'unit'   => trim(strip_tags($resultNodes2->item(2)->nodeValue)),
48 1
                    'descr'  => trim(strip_tags($tooltipNodes->item(2)->nodeValue)),
49 1
                ),
50
                'linkingRootDomains' => (object) array(
51 1
                    'result' => intval(str_replace(',', '', $resultNodes->item(3)->nodeValue)),
52 1
                    'unit'   => trim(strip_tags($resultNodes2->item(3)->nodeValue)),
53 1
                    'descr'  => trim(strip_tags($tooltipNodes->item(3)->nodeValue)),
54 1
                ),
55
                'totalLinks' => (object) array(
56 1
                    'result' => intval(str_replace(',', '', $resultNodes->item(4)->nodeValue)),
57 1
                    'unit'   => trim(strip_tags($resultNodes2->item(4)->nodeValue)),
58 1
                    'descr'  => trim(strip_tags($tooltipNodes->item(4)->nodeValue)),
59 1
                ),
60 1
            );
61
        }
62
        else {
63 1
            return parent::noDataDefaultValue();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (noDataDefaultValue() instead of getPageMetrics()). Are you sure this is correct? If so, you might want to change this to $this->noDataDefaultValue().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
64
        }
65
    }
66
}
67