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

EdgeLumaCalculator::apply()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 4
nop 1
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace AmaTeam\Image\Projection\Conversion\Processor\FXAA;
4
5
class EdgeLumaCalculator
6
{
7
    /**
8
     * @param Edge $edge
9
     *
10
     * @SuppressWarnings(PHPMD.ElseExpression)
11
     */
12
    public static function apply(Edge $edge)
13
    {
14
        if ($edge->horizontal) {
15
            $comparedLuma = $edge->inward ? $edge->luma->north : $edge->luma->south;
16
        } else {
17
            $comparedLuma = $edge->inward ? $edge->luma->west : $edge->luma->east;
18
        }
19
        $edge->averageLuma = ($edge->luma->center + $comparedLuma) / 2;
20
        $edge->gradient = abs($edge->luma->center - $comparedLuma);
21
        $edge->threshold = $edge->gradient / 4;
22
    }
23
}
24