RepositoryAware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createRepository() 0 3 1
A configure() 0 9 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Console\Command;
13
14
use CaptainHook\App\Console\Runtime\Resolver;
15
use SebastianFeldmann\Git\Repository;
16
use Symfony\Component\Console\Input\InputOption;
17
18
/**
19
 * Trait RepositoryAware
20
 *
21
 * Trait for all commands that needs to be aware of the git repository.
22
 *
23
 * @package CaptainHook\App\Console\Command
24
 */
25
class RepositoryAware extends ConfigAware
26
{
27
    /**
28
     * Configure method to set up the git-directory command option
29
     *
30
     * @return void
31
     */
32 35
    protected function configure(): void
33
    {
34 35
        parent::configure();
35
36 35
        $this->addOption(
37 35
            'git-directory',
38 35
            'g',
39 35
            InputOption::VALUE_OPTIONAL,
40 35
            'Path to your .git directory'
41 35
        );
42
    }
43
44
    /**
45
     * Create a new git repository representation
46
     *
47
     * @param  string $path
48
     * @return \SebastianFeldmann\Git\Repository
49
     */
50 29
    protected function createRepository(string $path): Repository
51
    {
52 29
        return Repository::createVerified($path);
53
    }
54
}
55