Passed
Push — master ( 7bee4d...457c92 )
by Sebastian
01:54
created

Prepare   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 19
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 2
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 CaptainHook\App\Hook\Message\Action;
11
12
use CaptainHook\App\Config;
13
use CaptainHook\App\Console\IO;
14
use CaptainHook\App\Hook\Action;
15
use SebastianFeldmann\Git\CommitMessage;
16
use SebastianFeldmann\Git\Repository;
17
18
/**
19
 * Class Prepare
20
 *
21
 * @package CaptainHook
22
 * @author  Sebastian Feldmann <[email protected]>
23
 * @link    https://github.com/captainhookphp/captainhook
24
 * @since   Class available since Release 3.1.0
25
 */
26
class Prepare implements Action
27
{
28
    /**
29
     * Executes the action
30
     *
31
     * @param  \CaptainHook\App\Config           $config
32
     * @param  \CaptainHook\App\Console\IO       $io
33
     * @param  \SebastianFeldmann\Git\Repository $repository
34
     * @param  \CaptainHook\App\Config\Action    $action
35
     * @return void
36
     * @throws \Exception
37
     */
38 2
    public function execute(Config $config, IO $io, Repository $repository, Config\Action $action) : void
39
    {
40 2
        $options = $action->getOptions();
41 2
        $oldMsg  = $repository->getCommitMsg();
42
43 2
        if (!$repository->isMerging()) {
44 2
            $repository->setCommitMsg(new CommitMessage($options->get('message', ''), $oldMsg->getCommentCharacter()));
45
        }
46 2
    }
47
}
48