Completed
Push — master ( f7d051...7cf7a4 )
by Sébastien
03:48
created

ReportRunnerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\Jasper;
6
7
use Soluble\Jasper\ReportRunner\ReportRunnerInterface;
8
use Soluble\Jasper\ReportRunner\JaphaJasperV6Runner;
9
use Soluble\Japha\Bridge\Adapter as BridgeAdapter;
10
11
class ReportRunnerFactory
12
{
13
    public const JAPHA_JASPER_V6 = 'japha_jasper_v6';
14
15
    public const SUPPORTED_RUNNERS = [
16
        self::JAPHA_JASPER_V6 => JaphaJasperV6Runner::class
17
    ];
18
19 2
    public function __invoke(BridgeAdapter $bridgeAdapter, string $runner = self::JAPHA_JASPER_V6): ReportRunnerInterface
20
    {
21 2
        if (!array_key_exists($runner, self::SUPPORTED_RUNNERS)) {
22 1
            throw new Exception\UnsupportedRunnerException(
23 1
                sprintf(
24 1
                    'Unsupported runner "%s", must be in (%s)',
25 1
                    $runner,
26 1
                    implode(',', array_keys(self::SUPPORTED_RUNNERS))
27
                )
28
            );
29
        }
30
31 1
        $class = self::SUPPORTED_RUNNERS[$runner];
32
33 1
        return new $class($bridgeAdapter);
34
    }
35
}
36