Scale::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 5
crap 3
1
<?php
2
3
namespace Undemanding\Difference\Transformation;
4
5
class Scale
6
{
7
    /**
8
     * New map of pixels scaled by a constant factor.
9
     *
10
     * @param array $bitmap
11
     * @param int $width
12
     * @param int $height
13
     * @param float $maximum
14
     * @param float $factor
15
     *
16
     * @return array
17
     */
18 1
    public function __invoke(array $bitmap, $width, $height, $maximum, $factor)
19
    {
20 1
        $new = [];
21
22 1
        for ($y = 0; $y < $height; $y++) {
23 1
            $new[$y] = [];
24
25 1
            for ($x = 0; $x < $width; $x++) {
26 1
                $new[$y][$x] = ($bitmap[$y][$x] / $maximum) * $factor;
27 1
            }
28 1
        }
29
30 1
        return $new;
31
    }
32
}
33