Maximum::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 7
Ratio 50 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 7
loc 14
ccs 10
cts 10
cp 1
rs 9.2
cc 4
eloc 7
nc 4
nop 3
crap 4
1
<?php
2
3
namespace Undemanding\Difference\Calculation;
4
5
class Maximum
6
{
7
    /**
8
     * Maximum difference for all bitmap pixels.
9
     *
10
     * @param array $bitmap
11
     * @param int $width
12
     * @param int $height
13
     *
14
     * @return float
15
     */
16 1
    public function __invoke(array $bitmap, $width, $height)
17
    {
18 1
        $maximum = 0;
19
20 1 View Code Duplication
        for ($y = 0; $y < $height; $y++) {
0 ignored issues
show
Duplication introduced by
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...
21 1
            for ($x = 0; $x < $width; $x++) {
22 1
                if ($bitmap[$y][$x] > $maximum) {
23 1
                    $maximum = $bitmap[$y][$x];
24 1
                }
25 1
            }
26 1
        }
27
28 1
        return (float) $maximum;
29
    }
30
}
31