Passed
Push — master ( d475b6...1e5be3 )
by Fabien
02:11
created

SequentialProcessHandler::process()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 5
nop 3
dl 0
loc 19
rs 9.8333
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Process\Handler;
4
5
use Churn\Collections\FileCollection;
6
use Churn\Process\Observer\OnSuccess;
7
use Churn\Process\ProcessFactory;
8
use Illuminate\Support\Collection;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Collection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class SequentialProcessHandler implements ProcessHandler
11
{
12
    /**
13
     * Run the processes sequentially to gather information.
14
     * @param FileCollection $filesCollection Collection of files.
15
     * @param ProcessFactory $processFactory  Process Factory.
16
     * @param OnSuccess      $onSuccess       The OnSuccess event observer.
17
     * @return Collection
18
     */
19
    public function process(
20
        FileCollection $filesCollection,
21
        ProcessFactory $processFactory,
22
        OnSuccess $onSuccess
23
    ): Collection {
24
        $completedProcessesArray = [];
25
        while ($filesCollection->hasFiles()) {
26
            $file = $filesCollection->getNextFile();
27
            $process = $processFactory->createGitCommitProcess($file);
28
            $process->start();
29
            while (!$process->isSuccessful());
30
            $completedProcessesArray[$process->getFileName()][$process->getType()] = $process;
31
            $process = $processFactory->createCyclomaticComplexityProcess($file);
32
            $process->start();
33
            while (!$process->isSuccessful());
34
            $completedProcessesArray[$process->getFileName()][$process->getType()] = $process;
35
            $onSuccess($file);
36
        }
37
        return new Collection($completedProcessesArray);
38
    }
39
}
40