RepositoryAware::createRepository()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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