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.
Passed
Push — master ( 4d892a...befb2e )
by Dušan
02:58
created

utility_functions.php ➔ compare()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12
Metric Value
cc 3
eloc 4
nc 3
nop 2
dl 0
loc 8
ccs 0
cts 3
cp 0
crap 12
rs 9.4285
1
<?php
2
3
namespace DusanKasan\Knapsack;
4
5
/**
6
 * Returns its argument.
7
 *
8
 * @param mixed $value
9
 * @return mixed
10
 */
11
function identity($value)
12
{
13 1
    return $value;
14
}
15
16
/**
17
 * Comparator. Returns a negative number, zero, or a positive number when x is logically 'less than', 'equal to', or
18
 * 'greater than' y.
19
 *
20
 * @param mixed $a
21
 * @param mixed $b
22
 * @return int
23
 */
24
function compare($a, $b)
25
{
26
    if ($a == $b) {
27
        return 0;
28
    }
29
30
    return $a < $b ? -1 : 1;
31
}
32
33
/**
34
 * Increments $value by one.
35
 *
36
 * @param int $value
37
 * @return int
38
 */
39
function increment($value)
40
{
41 1
    return $value + 1;
42
}
43
44
/**
45
 * Decrements $value by one.
46
 *
47
 * @param int $value
48
 * @return int
49
 */
50
function decrement($value)
51
{
52
    return $value - 1;
53
}
54
55
/**
56
 * Returns a sum of all arguments.
57
 *
58
 * @param int|float|double[] ...$values
59
 * @return number
60
 */
61
function sum(...$values)
62
{
63
    return array_sum($values);
64
}
65
66
/**
67
 * Returns the highest value from all arguments.
68
 *
69
 * @param int|float|double[] ...$values
70
 * @return mixed
71
 */
72
function max(...$values)
73
{
74
    return \max($values);
75
}
76
77
/**
78
 * Returns the lowest value from all arguments.
79
 *
80
 * @param int|float|double[] ...$values
81
 * @return mixed
82
 */
83
function min(...$values)
84
{
85
    return \min($values);
86
}
87
88
/**
89
 * @param int|float|double[] ...$values
90
 * @return float
91
 */
92
function average(...$values)
93
{
94
    return sum($values) / count($values);
95
}
96
97
/**
98
 * @param array ...$values
99
 * @return mixed
100
 */
101
function concatenate(...$values)
102
{
103
    return implode('', $values);
104
}
105