BaseProcessHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A saveResult() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Churn\Process\Handler;
6
7
use Churn\Process\ChangesCountInterface;
8
use Churn\Process\CyclomaticComplexityInterface;
9
use Churn\Process\ProcessInterface;
10
use Churn\Result\Result;
11
12
/**
13
 * @internal
14
 */
15
abstract class BaseProcessHandler implements ProcessHandler
16
{
17
    /**
18
     * @param ProcessInterface $process A successful process.
19
     * @param Result $result The result object to hydrate.
20
     */
21
    protected function saveResult(ProcessInterface $process, Result $result): Result
22
    {
23
        if ($process instanceof ChangesCountInterface) {
24
            $result->setCommits($process->countChanges());
25
        }
26
27
        if ($process instanceof CyclomaticComplexityInterface) {
28
            $result->setComplexity($process->getCyclomaticComplexity());
29
        }
30
31
        return $result;
32
    }
33
}
34