Completed
Push — master ( aa9657...bb9832 )
by Sebastian
05:21
created

CommitMsg   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 31
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A setup() 0 4 1
1
<?php
2
/**
3
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\CaptainHook\Console\Command\Hook;
11
12
use SebastianFeldmann\CaptainHook\Config;
13
use SebastianFeldmann\CaptainHook\Console\Command\Hook;
14
use SebastianFeldmann\Git;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Class CommitMessage
21
 *
22
 * @package CaptainHook
23
 * @author  Sebastian Feldmann <[email protected]>
24
 * @link    https://github.com/sebastianfeldmann/captainhook
25
 * @since   Class available since Release 0.9.0
26
 */
27
class CommitMsg extends Hook
28
{
29
    /**
30
     * Hook to execute.
31
     *
32
     * @var string
33
     */
34
    protected $hookName = 'commit-msg';
35
36
    /**
37
     * Configure the command.
38
     */
39 2
    protected function configure()
40
    {
41 2
        parent::configure();
42 2
        $this->addArgument('file', InputArgument::REQUIRED, 'File containing the commit message.');
43 2
    }
44
45
    /**
46
     * Read the commit message from file.
47
     *
48
     * @param \Symfony\Component\Console\Input\InputInterface   $input
49
     * @param \Symfony\Component\Console\Output\OutputInterface $output
50
     * @param \SebastianFeldmann\CaptainHook\Config             $config
51
     * @param \SebastianFeldmann\Git\Repository                 $repository
52
     */
53
    protected function setup(InputInterface $input, OutputInterface $output, Config $config, Git\Repository $repository)
54
    {
55 1
        $repository->setCommitMsg(Git\CommitMessage::createFromFile($input->getFirstArgument()));
56
    }
57
}
58