Average   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 3
1
<?php
2
3
namespace Undemanding\Difference\Calculation;
4
5
class Average
6
{
7
    /**
8
     * Average 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
        $average = 0;
19
20 1
        for ($y = 0; $y < $height; $y++) {
21 1
            for ($x = 0; $x < $width; $x++) {
22 1
                $average += $bitmap[$y][$x];
23 1
            }
24 1
        }
25
26 1
        $average /= ($width * $height);
27
28 1
        return (float) $average;
29
    }
30
}
31