BaseProcessHandler::saveResult()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 3
nc 4
nop 2
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