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.

Shodan   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 9
eloc 19
c 2
b 1
f 0
dl 0
loc 74
ccs 19
cts 19
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUrl() 0 6 1
A getResults() 0 8 3
A check() 0 11 3
A __construct() 0 3 1
A getUrl() 0 3 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 "Shodan.php" doesn't match the expected filename "shodan.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace RattfieldNz\Shodan;
4
5
use ErrorException;
6
use RattfieldNz\Shodan\Libraries\Curl\Curl;
7
use RattfieldNz\Shodan\Libraries\Data\Data;
8
9
/**
10
 * Class Shodan.
11
 *
12
 * @category PHP
0 ignored issues
show
Coding Style Documentation introduced by
@category tag is not allowed in class comment
Loading history...
13
 *
14
 * @author  Rob Attfield <[email protected]>
0 ignored issues
show
Coding Style Documentation introduced by
@author tag is not allowed in class comment
Loading history...
15
 * @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...
16
 */
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...
17
class Shodan
18
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Shodan
Loading history...
19
    private $_url;
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...
20
21
    private $_results;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
22
23
    private $_data;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
24
25 6
    public function __construct()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
26
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
27 6
        $this->_results = null;
0 ignored issues
show
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...
28 6
    }
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 __construct()
Loading history...
29
30
    /**
31
     * Add URL to be checked with Shodan API.
32
     *
33
     * @param string $url The URL to be checked.
34
     *
35
     * @return Shodan.
0 ignored issues
show
Documentation Bug introduced by
The doc comment Shodan. at position 0 could not be parsed: Unknown type name 'Shodan.' at position 0 in Shodan..
Loading history...
36
     */
37 4
    public function setUrl(string $url)
38
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
39 4
        $this->_url = $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...
40 4
        $this->_data = new Data($this->_url);
41
42 4
        return $this;
43
    }
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 setUrl()
Loading history...
44
45
    /**
46
     * Checks a given URL with Shodan API.
47
     *
48
     * @throws ErrorException
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
49
     *
50
     * @return Shodan
51
     */
52 2
    public function check()
53
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
54
        $error = [
0 ignored issues
show
Coding Style introduced by
Short array syntax is not allowed
Loading history...
55 2
            'status'   => 500,
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 18 spaces, but found 12.
Loading history...
56
            'response' => 'URL cannot be null.',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 18 spaces, but found 12.
Loading history...
57
        ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 17 space(s), but found 8.
Loading history...
58
59 2
        $this->_results = empty($this->getUrl()) || empty($this->_data) ?
0 ignored issues
show
Coding Style introduced by
The value of a boolean operation must not be assigned to a variable
Loading history...
Coding Style introduced by
Boolean operators are not allowed outside of control structure conditions
Loading history...
Coding Style introduced by
Expected 1 space after "?"; newline found
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
60 2
            $error : (new Curl($this->_data))->getData();
61
62 2
        return $this;
63
    }
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 check()
Loading history...
64
65
    /**
66
     * Get current URL.
67
     *
68
     * @return string|null
69
     */
70 4
    public function getUrl()
71
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
72 4
        return $this->_url;
73
    }
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 getUrl()
Loading history...
74
75
    /**
76
     * Get results of Shodan API call.
77
     *
78
     * @param bool $jsonEncode Encode results as JSON, or
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for parameter type
Loading history...
79
     *                         return as associative array.
80
     *
81
     * @return mixed|null
82
     */
83 3
    public function getResults(bool $jsonEncode = false)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$jsonEncode" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$jsonEncode"; expected 0 but found 1
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
84
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
85 3
        if (empty($this->_results)) {
86 1
            return;
0 ignored issues
show
introduced by
Function return type is not void, but function is returning void here
Loading history...
87
        }
88
89 2
        return $jsonEncode === false ?
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
Coding Style introduced by
Expected 1 space after "?"; newline found
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
90 2
            $this->_results : json_encode($this->_results);
91
    }
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 getResults()
Loading history...
92
}
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...
93