Completed
Pull Request — master (#32)
by
unknown
09:15
created

TemplateBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 3
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
    public static function build(InputInterface $input, Config $config, Repository $repository): Template
22
    {
23
        if ($input->getOption('run-mode') === Template::DOCKER) {
24
            return new Docker(
25
                realpath($repository->getRoot()),
26
                getcwd() . '/vendor',
27
                $input->getOption('container-name')
28
            );
29
        }
30
31
        return new Local(
32
            realpath($repository->getRoot()),
33
            getcwd() . '/vendor',
34
            realpath($config->getPath())
35
        );
36
    }
37
}