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.

Issues (917)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Utility/Time.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Nip\Utility;
4
5
class Time
6
{
7
8
    protected $_value = null;
9
    protected $_parts = null;
10
    protected $_seconds = null;
11
12
    public static function fromString($string)
13
    {
14
        $o = new self();
15
        $o->_value = $string;
16
        $o->parseSeconds();
17
18
        return $o;
19
    }
20
21
    public function parseSeconds()
22
    {
23
        $parts = $this->getParts();
24
        if (count($parts) == 3) {
25
            $seconds = 0;
26
            $seconds += $parts['h'] * 3600;
27
            $seconds += $parts['m'] * 60;
28
            $seconds += $parts['s'];
29
            $this->setSeconds($seconds);
30
        }
31
    }
32
33
    public function getParts()
34
    {
35
        if ($this->_parts === null) {
36
            $this->parseParts();
37
        }
38
39
        return $this->_parts;
40
    }
41
42
    /**
43
     * @param array $parts
44
     */
45
    public function setParts($parts)
46
    {
47
        $this->_parts = $parts;
48
    }
49
50
    public function parseParts()
51
    {
52
        if ($this->_value && substr_count($this->_value, ':') == 2) {
53
            $this->parsePartsFromString();
54
        } elseif ($this->_seconds > 0) {
55
            $this->parsePartsFromSeconds();
56
        }
57
    }
58
59
    public function parsePartsFromString()
60
    {
61
        list ($h, $m, $s) = explode(':', $this->_value);
62
63
        $this->setHoursPart($h);
64
        $this->setMinutesPart($m);
65
        $this->setSecondsPart($s);
66
    }
67
68
    /**
69
     * @param string $v
70
     */
71
    public function setHoursPart($v)
72
    {
73
        $this->setPart('h', $v);
74
    }
75
76
    /**
77
     * @param string $p
78
     * @param string $v
79
     */
80
    public function setPart($p, $v)
81
    {
82
        $this->_parts[$p] = $v;
83
    }
84
85
    /**
86
     * @param string $v
87
     */
88
    public function setMinutesPart($v)
89
    {
90
        $this->setPart('m', $v);
91
    }
92
93
    /**
94
     * @param string $v
95
     */
96
    public function setSecondsPart($v)
97
    {
98
        $this->setPart('s', $v);
99
    }
100
101
    public function parsePartsFromSeconds()
102
    {
103
        $seconds = $this->getSeconds();
104
        if ($hours = intval((floor($seconds / 3600)))) {
105
            $seconds = $seconds - $hours * 3600;
106
        }
107
108
        $this->setHoursPart($hours);
109
110
        if ($minutes = intval((floor($seconds / 60)))) {
111
            $seconds = $seconds - $minutes * 60;
112
        }
113
114
        $this->setMinutesPart($minutes);
115
116
        $seconds = round($seconds, 2);
117
        $this->setSecondsPart($seconds);
118
119
    }
120
121
    public function getSeconds()
122
    {
123
        if ($this->_seconds === null) {
124
            $this->parseSeconds();
125
        }
126
127
        return $this->_seconds;
128
    }
129
130
    /**
131
     * @param null $seconds
132
     */
133
    public function setSeconds($seconds)
134
    {
135
        $this->_seconds = $seconds;
136
    }
137
138
    public static function fromSeconds($seconds)
139
    {
140
        $o = new self();
141
        $o->setSeconds($seconds);
142
143
        return $o;
144
    }
145
146
    public function getFormatedString()
147
    {
148
        $return = '';
149
150
        $hours = $this->getHoursPart();
151
        if ($hours OR $return) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
152
            $return .= ($return ? ' ' : '').str_pad($hours, 2, 0, STR_PAD_LEFT).'h';
153
        }
154
155
        $minutes = $this->getMinutesPart();
156
        if ($minutes OR $return) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
157
            $return .= ($return ? ' ' : '').str_pad($minutes, 2, 0, STR_PAD_LEFT).'m';
158
        }
159
160
        $seconds = $this->getSecondsPart();
161 View Code Duplication
        if ($seconds) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
162
            $return .= ($return ? ' ' : '').str_pad($seconds, 2, 0, STR_PAD_LEFT).'s';
163
        }
164
165
        return $return;
166
    }
167
168
    public function getHoursPart()
169
    {
170
        return $this->getPart('h');
171
    }
172
173
    public function getPart($p)
174
    {
175
        if ($this->_parts === null) {
176
            $this->parseParts();
177
        }
178
179
        return $this->_parts[$p];
180
    }
181
182
    public function getMinutesPart()
183
    {
184
        return $this->getPart('m');
185
    }
186
187
    public function getSecondsPart()
188
    {
189
        return $this->getPart('s');
190
    }
191
192
    public function getDefaultString()
193
    {
194
        $hours = str_pad($this->getHoursPart(), 2, 0, STR_PAD_LEFT);
195
        $minutes = str_pad($this->getMinutesPart(), 2, 0, STR_PAD_LEFT);
196
        $seconds = str_pad($this->getSecondsPart(), 2, 0, STR_PAD_LEFT);
197
198
        return $hours.':'.$minutes.':'.$seconds;
199
    }
200
}