Passed
Pull Request — master (#32)
by
unknown
02:23
created

TemplateBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 14
ccs 10
cts 10
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace CaptainHook\App\Hook;
5
6
use CaptainHook\App\Config;
7
use CaptainHook\App\Hook\Template\Docker;
8
use CaptainHook\App\Hook\Template\Local;
9
use SebastianFeldmann\Git\Repository;
10
use Symfony\Component\Console\Input\InputInterface;
11
12
abstract class TemplateBuilder
13
{
14
    /**
15
     * @param InputInterface $input
16
     * @param Config         $config
17
     * @param Repository     $repository
18
     *
19
     * @return Template
20
     */
21 5
    public static function build(InputInterface $input, Config $config, Repository $repository): Template
22
    {
23 5
        if ($input->getOption('run-mode') === Template::DOCKER) {
24 1
            return new Docker(
25 1
                realpath($repository->getRoot()),
26 1
                getcwd() . '/vendor',
27 1
                $input->getOption('container-name')
28
            );
29
        }
30
31 4
        return new Local(
32 4
            realpath($repository->getRoot()),
33 4
            getcwd() . '/vendor',
34 4
            realpath($config->getPath())
35
        );
36
    }
37
}