Passed
Push — master ( eba56b...0dd639 )
by Sebastian
01:52
created

RepositoryAware::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 0
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
     * Runtime resolver to check for PHAR or lib execution
29
     *
30
     * @var \CaptainHook\App\Console\Runtime\Resolver
31
     */
32
    protected $resolver;
33
34
    /**
35
     * Configure method to setup the git-directory command option
36
     *
37
     * @return void
38
     */
39
    protected function configure(): void
40
    {
41
        parent::configure();
42
43
        $this->addOption(
44
            'git-directory',
45
            'g',
46
            InputOption::VALUE_OPTIONAL,
47
            'Path to your .git directory'
48
        );
49
    }
50
51
    /**
52
     * Create a new git repository representation
53
     *
54
     * @param  string $path
55
     * @return \SebastianFeldmann\Git\Repository
56
     */
57
    protected function createRepository(string $path): Repository
58
    {
59
        return Repository::createVerified($path);
60
    }
61
}
62