Maximum   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 26.92 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 7
loc 26
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 7 14 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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