ReducedStandardDeviation   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 25.93 %

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 27
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\Transformation;
4
5
class ReducedStandardDeviation
6
{
7
    /**
8
     * New map of pixels with those in the standard deviation removed.
9
     *
10
     * @param array $bitmap
11
     * @param int $width
12
     * @param int $height
13
     * @param float $deviation
14
     *
15
     * @return array
16
     */
17 1
    public function __invoke(array $bitmap, $width, $height, $deviation)
18
    {
19 1
        $new = array_slice($bitmap, 0);
20
21 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...
22 1
            for ($x = 0; $x < $width; $x++) {
23 1
                if (abs($new[$y][$x]) < $deviation) {
24 1
                    $new[$y][$x] = 0;
25 1
                }
26 1
            }
27 1
        }
28
29 1
        return $new;
30
    }
31
}
32