EuclideanDistance   A
last analyzed

Complexity

Total Complexity 1

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 1
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 26
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 1
1
<?php
2
3
namespace Undemanding\Difference\Method;
4
5
class EuclideanDistance
6
{
7
    /**
8
     * RGB color distance for the same pixel in two images.
9
     *
10
     * @link https://en.wikipedia.org/wiki/Euclidean_distance
11
     *
12
     * @param array $p
13
     * @param array $q
14
     *
15
     * @return float
16
     */
17 1
    public function __invoke(array $p, array $q)
18
    {
19 1
        $r = $p["r"] - $q["r"];
20 1
        $r *= $r;
21
22 1
        $g = $p["g"] - $q["g"];
23 1
        $g *= $g;
24
25 1
        $b = $p["b"] - $q["b"];
26 1
        $b *= $b;
27
28 1
        return (float) sqrt($r + $g + $b);
29
    }
30
}
31