Percentage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

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 0
loc 29
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 17 4
1
<?php
2
3
namespace Undemanding\Difference\Calculation;
4
5
class Percentage
6
{
7
    /**
8
     * Percentage of different pixels in the bitmap.
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
        $total = 0;
19 1
        $different = 0;
20
21 1
        for ($y = 0; $y < $height; $y++) {
22 1
            for ($x = 0; $x < $width; $x++) {
23 1
                $total++;
24
25 1
                if ($bitmap[$y][$x] > 0) {
26 1
                    $different++;
27 1
                }
28 1
            }
29 1
        }
30
31 1
        return (float) (($different / $total) * 100);
32
    }
33
}
34