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.
Test Failed
Branch master (c3101c)
by Rob
03:35 queued 28s
created

Curl::_setDefaultHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
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 "Curl.php" doesn't match the expected filename "curl.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace RattfieldNz\Shodan\Libraries\Curl;
4
5
use Curl\Curl as PhpCurl;
6
use RattfieldNz\Shodan\Libraries\Data\Data;
7
8
/**
9
 * Class Curl.
10
 *
11
 * @category PHP
0 ignored issues
show
Coding Style Documentation introduced by
@category tag is not allowed in class comment
Loading history...
12
 *
13
 * @author  Rob Attfield <[email protected]>
0 ignored issues
show
Coding Style Documentation introduced by
@author tag is not allowed in class comment
Loading history...
introduced by
Tag value indented incorrectly; expected 1 space but found 2
Loading history...
14
 * @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...
15
 */
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...
16
class Curl
17
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Curl
Loading history...
introduced by
Opening brace should be on the same line as the declaration
Loading history...
18
    private $_data;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
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...
introduced by
Class property $_data should use lowerCamel naming without underscores
Loading history...
19
    private $_defaultHeaders;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
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...
introduced by
Class property $_defaultHeaders should use lowerCamel naming without underscores
Loading history...
20
    private $_timeout;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
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...
introduced by
Class property $_timeout should use lowerCamel naming without underscores
Loading history...
21
    private $_curl;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
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...
introduced by
Class property $_curl should use lowerCamel naming without underscores
Loading history...
22
23
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
24
     * Curl constructor.
25
     *
26
     * Set the needed properties to do a CURL request.
27
     *
28
     * @param Data $data    Data to use when executing cURL.
0 ignored issues
show
introduced by
Data types in @param tags need to be fully namespaced
Loading history...
introduced by
Parameter comment must be on the next line
Loading history...
29
     * @param int  $timeout Timeout in seconds to complete a CURL request. Default is 10.
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
introduced by
Parameter comment must be on the next line
Loading history...
30
     *
31
     * @throws \ErrorException Will throw an exception if PHP ext-curl is not installed.
0 ignored issues
show
introduced by
@throws comment must be on the next line
Loading history...
32
     */
33
    public function __construct(Data $data, int $timeout = 10)
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
34
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
35
        if (!extension_loaded('curl')) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
36
            throw new \ErrorException(
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
37
                'The cURL extensions is not loaded, make sure you have installed the cURL extension: https://php.net/manual/curl.setup.php'
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
38
            );
39
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
40
41
        $this->_curl = new PhpCurl();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
42
        $this->_data = $data;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
43
        $this->_timeout = $timeout;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
44
        $this->_setDefaultHeaders();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
45
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
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...
46
47
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
48
     * Execute a CURL request, and return current object for further processing.
49
     *
50
     * @return PhpCurl
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
introduced by
Data types in @return tags need to be fully namespaced
Loading history...
51
     */
52
    public function execute(): PhpCurl
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
53
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
54
        $this->_curl->setOpt(CURLOPT_RETURNTRANSFER, true);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
55
        $this->_curl->setOpt(CURLOPT_CONNECTTIMEOUT, $this->_timeout);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
56
        $this->_curl->setOpt(CURLOPT_HTTPHEADER, $this->_defaultHeaders);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
57
        $this->_curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
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...
58
        $this->_curl->setOpt(CURLOPT_SSL_VERIFYHOST, false);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
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...
59
        $this->_curl->get($this->_data->shodanApiUrl());
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
60
61
        return $this->_curl;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
62
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end execute()
Loading history...
63
64
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
65
     * Get the data retrieved from executing CURL request, in JSON format.
66
     *
67
     * @return string
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
68
     *
69
     * @see \RattfieldNz\SafeUrls\Libraries\Curl\Curl->execute().
0 ignored issues
show
introduced by
Trailing punctuation for @see references is not allowed.
Loading history...
70
     */
71
    public function getData()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
72
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
73
        $dataObject = $this->execute();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
74
        $data = [
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 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...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
75
            'status'   => $dataObject->getHttpStatus(),
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
76
            'response' => json_decode($dataObject->response, true),
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
77
        ];
78
79
        return json_encode($data);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
80
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getData()
Loading history...
81
82
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
83
     * Sets the default headers to use for CURL request.
84
     *
85
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
introduced by
Description for the @return value is missing
Loading history...
86
     */
87
    private function _setDefaultHeaders(): void
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
introduced by
Private method name "Curl::_setDefaultHeaders" is not in lowerCamel format
Loading history...
88
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
89
        $this->_defaultHeaders = [
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
90
            'Content-Type: application/json',
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
91
            'Connection: Keep-Alive',
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
92
        ];
93
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line 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 _setDefaultHeaders()
Loading history...
94
}
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...
95