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.

JobConfig::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 3
1
<?php
2
3
namespace Jamal\JenkinsArduino\Jenkins;
4
5
use StdClass;
6
7
/**
8
 * @author Caio Almeida <[email protected]>
9
 */
10
class JobConfig extends StdClass
11
{
12
    /**
13
     * Jenkins server name.
14
     * @var string
15
     */
16
    public $server;
17
18
    /**
19
     * Jenkins port default: 80
20
     * @var integer
21
     */
22
    public $port = 80;
23
24
    /**
25
     * Job name.
26
     * @var string
27
     */
28
    public $jobName;
29
30
    /**
31
     * Http protocol
32
     * @var string
33
     */
34
    public $protocol = 'http';
35
36
    /**
37
     * @var Credentials
38
     */
39
    public $credentials;
40
41
    /**
42
     * @param string $jobName
43
     * @param string $server
44
     * @param int $port
45
     */
46
    public function __construct($jobName, $server, $port = null)
47
    {
48
        if (is_integer($port)) {
49
            $this->port = $port;
50
        }
51
52
        $this->server  = $server;
53
        $this->jobName = $jobName;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function toUrl()
60
    {
61
        $credentials = null;
62
63
        if ($this->hasCredentials()) {
64
            $credentials = sprintf(
65
                '%s:%s@',
66
                $this->credentials->user,
67
                $this->credentials->token
68
            );
69
        }
70
71
        return strtr(
72
            '{protocol}://{credentials}{server}:{port}/job/{jobName}/lastBuild/api/json',
73
            [
74
                '{protocol}'    => $this->protocol,
75
                '{server}'      => $this->server,
76
                '{port}'        => $this->port,
77
                '{jobName}'     => $this->jobName,
78
                '{credentials}' => $credentials
79
            ]
80
        );
81
    }
82
83
    /**
84
     * @param Credentials $credentials
85
     * @return JobConfig
86
     */
87
    public function setCredentials(Credentials $credentials)
88
    {
89
        $this->credentials = $credentials;
90
        return $this;
91
    }
92
93
    public function hasCredentials()
94
    {
95
        return ($this->credentials instanceof Credentials);
96
    }
97
}
98