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.

Data::getUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "Data.php" doesn't match the expected filename "data.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace RattfieldNz\Shodan\Libraries\Data;
4
5
use RattfieldNz\Shodan\Libraries\Config\Config;
6
7
/**
8
 * Class Data.
9
 *
10
 * @category PHP
0 ignored issues
show
Coding Style Documentation introduced by
@category tag is not allowed in class comment
Loading history...
11
 *
12
 * @author  Rob Attfield <[email protected]>
0 ignored issues
show
Coding Style Documentation introduced by
@author tag is not allowed in class comment
Loading history...
13
 * @license https://github.com/rattfieldnz/shodan/blob/master/LICENSE MIT
0 ignored issues
show
Coding Style Documentation introduced by
@license tag is not allowed in class comment
Loading history...
14
 */
0 ignored issues
show
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
15
class Data
16
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Data
Loading history...
17
    private $_ip;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
18
    private $_url;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
19
20 11
    public function __construct(string $url)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
21
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
22 11
        $this->_url = $url;
23 11
        $this->_ip = $this->getIp($this->_url);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
24 11
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __construct()
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
25
26
    /**
27
     * Get Shodan API URL with key.
28
     *
29
     * @return string
30
     */
31 4
    public function shodanApiUrl()
32
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
33 4
        return 'https://api.shodan.io/shodan/host/'.$this->_ip.'?key='.
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
34 4
            Config::shodanApiKey();
35
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end shodanApiUrl()
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
36
37
    /**
38
     * Get IPv4 address from a URL.
39
     *
40
     * @param string $url
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
41
     *
42
     * @return string|null
43
     */
44 11
    public function getIp(string $url)
45
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
46 11
        $domain = parse_url($url);
47 11
        if (empty($domain['host'])) {
48 1
            return;
0 ignored issues
show
introduced by
Function return type is not void, but function is returning void here
Loading history...
49
        }
50
51 11
        $ip = gethostbyname($domain['host']);
52
53 11
        return filter_var($ip, FILTER_VALIDATE_IP) ? $ip : null;
0 ignored issues
show
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
54
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getIp()
Loading history...
55
56
    /**
57
     * Returns URL set when initialising Data object.
58
     *
59
     * @return string
60
     */
61 3
    public function getUrl()
62
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
63 3
        return $this->_url;
64
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getUrl()
Loading history...
65
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
66