Prepare   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

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