Passed
Push — master ( b649b5...b34030 )
by Sebastian
04:07
created

Base   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
execute() 0 1 ?
A executeValidator() 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\Hook\Message;
11
12
use CaptainHook\Config;
13
use CaptainHook\Console\IO;
14
use CaptainHook\Git\Repository;
15
use CaptainHook\Hook\Action;
16
17
/**
18
 * Class Base
19
 *
20
 * @package CaptainHook
21
 * @author  Sebastian Feldmann <[email protected]>
22
 * @link    https://github.com/sebastianfeldmann/captainhook
23
 * @since   Class available since Release 0.9.0
24
 */
25
abstract class Base implements Action
26
{
27
    /**
28
     * Execute the configured action.
29
     *
30
     * @param  \CaptainHook\Config         $config
31
     * @param  \CaptainHook\Console\IO     $io
32
     * @param  \CaptainHook\Git\Repository $repository
33
     * @param  \CaptainHook\Config\Action  $action
34
     * @throws \CaptainHook\Exception\ActionExecution
35
     */
36
    abstract public function execute(Config $config, IO $io, Repository $repository, Config\Action $action);
37
38
    /**
39
     * Validate the message.
40
     *
41
     * @param \CaptainHook\Hook\Message\Validator $validator
42
     * @param \CaptainHook\Git\Repository         $repository
43
     */
44 4
    protected function executeValidator(Validator $validator, Repository $repository)
45
    {
46
        // if this is no merge commit enforce message rules
47 4
        if (!$repository->isMerging()) {
48 4
            $validator->validate($repository->getCommitMsg());
49
        }
50 3
    }
51
}
52