Passed
Push — dev ( e9cf15...64faf7 )
by Fike
03:26
created

EdgeOrientationCalculator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 12 1
1
<?php
2
3
namespace AmaTeam\Image\Projection\Conversion\Processor\FXAA;
4
5
class EdgeOrientationCalculator
6
{
7
    public static function apply(Edge $edge)
8
    {
9
        $grid = $edge->luma;
10
        $vertical =
11
            abs(($grid->northWest / 4) - ($grid->north / 2) + ($grid->northEast / 4)) +
12
            abs(($grid->west / 2) - $grid->center + ($grid->east / 2)) +
13
            abs(($grid->southWest) / 4) - ($grid->south / 2) + ($grid->southEast / 4);
14
        $horizontal =
15
            abs(($grid->northWest / 4) - ($grid->west / 2) + ($grid->southWest / 4)) +
16
            abs(($grid->north / 2) - $grid->center + ($grid->south / 2)) +
17
            abs(($grid->northEast / 4) - ($grid->east / 2) + ($grid->southEast / 4));
18
        $edge->horizontal = $horizontal >= $vertical;
19
    }
20
}
21