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.
Completed
Push — master ( e2875b...35ced9 )
by Anton
03:41
created

Validator::isVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Deployer\Component\PharUpdate\Version;
4
5
/**
6
 * Validates version information.
7
 *
8
 * @author Kevin Herrera <[email protected]>
9
 */
10
class Validator
11
{
12
    /**
13
     * The regular expression for a valid identifier.
14
     */
15
    const IDENTIFIER_REGEX = '/^[0-9A-Za-z\-]+$/';
16
17
    /**
18
     * The regular expression for a valid semantic version number.
19
     */
20
    const VERSION_REGEX = '/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/';
21
22
    /**
23
     * Checks if a identifier is valid.
24
     *
25
     * @param string $identifier A identifier.
26
     *
27
     * @return boolean TRUE if the identifier is valid, FALSE If not.
28
     */
29
    public static function isIdentifier($identifier)
30
    {
31
        return (true == preg_match(self::IDENTIFIER_REGEX, $identifier));
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing preg_match(self::IDENTIFIER_REGEX, $identifier) of type integer to the boolean true. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
32
    }
33
34
    /**
35
     * Checks if a number is a valid version number.
36
     *
37
     * @param integer $number A number.
38
     *
39
     * @return boolean TRUE if the number is valid, FALSE If not.
40
     */
41
    public static function isNumber($number)
42
    {
43
        return (true == preg_match('/^(0|[1-9]\d*)$/', $number));
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing preg_match('/^(0|[1-9]\\d*)$/', $number) of type integer to the boolean true. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
44
    }
45
46
    /**
47
     * Checks if the string representation of a version number is valid.
48
     *
49
     * @param string $version The string representation.
50
     *
51
     * @return boolean TRUE if the string representation is valid, FALSE if not.
52
     */
53
    public static function isVersion($version)
54
    {
55
        return (true == preg_match(self::VERSION_REGEX, $version));
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing preg_match(self::VERSION_REGEX, $version) of type integer to the boolean true. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
56
    }
57
}
58