Passed
Push — master ( 1f8075...93e91b )
by Fabien
02:17
created

BaseProcessHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
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 18
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
abstract class BaseProcessHandler implements ProcessHandler
13
{
14
15
    /**
16
     * @param ProcessInterface $process A successful process.
17
     * @param Result $result The result object to hydrate.
18
     */
19
    protected function saveResult(ProcessInterface $process, Result $result): Result
20
    {
21
        if ($process instanceof ChangesCountInterface) {
22
            $result->setCommits($process->countChanges());
23
        }
24
25
        if ($process instanceof CyclomaticComplexityInterface) {
26
            $result->setComplexity($process->getCyclomaticComplexity());
27
        }
28
29
        return $result;
30
    }
31
}
32