ProcessHandlerFactory::getProcessHandler()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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