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::scaffoldFormField()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 1
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