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.

ExternalURL   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 79.17%

Importance

Changes 0
Metric Value
wmc 11
lcom 2
cbo 2
dl 0
loc 66
ccs 19
cts 24
cp 0.7917
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A Nice() 0 11 4
A Domain() 0 6 2
A NoWWW() 0 4 1
A scaffoldFormField() 0 7 1
A forTemplate() 0 6 2
1
<?php
2
3
namespace BurnBright\ExternalURLField;
4
5
use BurnBright\ExternalURLField\ExternalURLField;
6
use SilverStripe\ORM\FieldType\DBVarchar;
7
8
class ExternalURL extends DBVarchar
9
{
10
    private static $casting = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
11
        "Domain" => "ExternalURL",
12
        "URL" => "ExternalURL"
13
    );
14
15
    /**
16
     * 2083 is the lowest common denominator when it comes to url lengths.
17
     */
18 4
    public function __construct($name = null, $size = 2083, $options = array())
19
    {
20 4
        parent::__construct($name, $size, $options);
21 4
    }
22
23
    /**
24
     * Remove ugly parts of a url to make it nice
25
     */
26 1
    public function Nice()
27
    {
28 1
        if ($this->value && $parts = parse_url($this->URL())) {
29 1
            $remove = array('scheme', 'user', 'pass', 'port', 'query', 'fragment');
30 1
            foreach ($remove as $part) {
31 1
                unset($parts[$part]);
32
            }
33
34 1
            return rtrim(http_build_url($parts), "/");
35
        }
36
    }
37
38
    /**
39
     * Get just the domain of the url.
40
     */
41 1
    public function Domain()
42
    {
43 1
        if ($this->value) {
44 1
            return parse_url($this->URL(), PHP_URL_HOST);
45
        }
46
    }
47
48
    /**
49
     * Remove the www subdomain, if present.
50
     */
51
    public function NoWWW()
52
    {
53
        return ltrim($this->value, "www.");
54
    }
55
56
    /**
57
     * Scaffold the ExternalURLField for this ExternalURL
58
     */
59 1
    public function scaffoldFormField($title = null, $params = null)
60
    {
61 1
        $field = new ExternalURLField($this->name, $title);
62 1
        $field->setMaxLength($this->getSize());
63
64 1
        return $field;
65
    }
66
67 1
    public function forTemplate()
68
    {
69 1
        if ($this->value) {
70 1
            return $this->URL();
71
        }
72
    }
73
}
74