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

Base::executeValidator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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