Completed
Push — master ( 016444...91d1a7 )
by Sebastian
02:32
created

Book   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
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 27
ccs 4
cts 4
cp 1
rs 10

2 Methods

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