Passed
Pull Request — master (#233)
by Fabien
02:33
created

SequentialProcessHandler::process()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 12
c 1
b 0
f 0
nc 5
nop 2
dl 0
loc 17
rs 9.8666
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Processes\Handler;
4
5
use Churn\Collections\FileCollection;
6
use Churn\Factories\ProcessFactory;
7
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...
8
9
class SequentialProcessHandler implements ProcessHandler
10
{
11
    /**
12
     * Run the processes sequentially to gather information.
13
     * @param FileCollection $filesCollection Collection of files.
14
     * @param ProcessFactory $processFactory  Process Factory.
15
     * @return Collection
16
     */
17
    public function process(
18
        FileCollection $filesCollection,
19
        ProcessFactory $processFactory
20
    ): Collection {
21
        $completedProcessesArray = [];
22
        while ($filesCollection->hasFiles()) {
23
            $file = $filesCollection->getNextFile();
24
            $process = $processFactory->createGitCommitProcess($file);
25
            $process->start();
26
            while (!$process->isSuccessful());
27
            $completedProcessesArray[$process->getFileName()][$process->getType()] = $process;
28
            $process = $processFactory->createCyclomaticComplexityProcess($file);
29
            $process->start();
30
            while (!$process->isSuccessful());
31
            $completedProcessesArray[$process->getFileName()][$process->getType()] = $process;
32
        }
33
        return new Collection($completedProcessesArray);
34
    }
35
}
36