Completed
Pull Request — master (#32)
by
unknown
03:08 queued 01:48
created

TemplateBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 14 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
}