Completed
Pull Request — master (#283)
by Oskar
02:45
created

PackageDistance   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
rs 10
wmc 5
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B calculate() 0 8 5
1
<?php
2
declare(strict_types=1);
3
namespace Hal\Metric\Package;
4
5
use Hal\Metric\Metrics;
6
use Hal\Metric\PackageMetric;
7
8
class PackageDistance
9
{
10
    public function calculate(Metrics $metrics)
11
    {
12
        foreach ($metrics->all() as $each) {
13
            if ($each instanceof PackageMetric && $each->getAbstraction() !== null && $each->getInstability() !== null) {
14
                $each->setNormalizedDistance(abs($each->getAbstraction() + $each->getInstability() - 1));
15
            }
16
        }
17
    }
18
}
19