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

ProcessHandlerFactory::getProcessHandler()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Processes;
4
5
use Churn\Configuration\Config;
6
use Churn\Processes\Handler\ParallelProcessHandler;
7
use Churn\Processes\Handler\ProcessHandler;
8
use Churn\Processes\Handler\SequentialProcessHandler;
9
10
class ProcessHandlerFactory
11
{
12
    /**
13
     * Returns a process handler depending on the configuration.
14
     * @param Config $config The application configuration.
15
     * @return ProcessHandler
16
     */
17
    public function getProcessHandler(Config $config): ProcessHandler
18
    {
19
        if ($config->getParallelJobs() > 1) {
20
            return new ParallelProcessHandler($config->getParallelJobs());
21
        }
22
23
        return new SequentialProcessHandler();
24
    }
25
}
26