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

Beams::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
ccs 12
cts 12
cp 1
rs 9.4285
cc 1
eloc 11
nc 1
nop 4
crap 1
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\Message\Rule;
16
use sebastianfeldmann\CaptainHook\Hook\Message\RuleBook;
17
18
/**
19
 * Class Beams
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
class Beams extends Book
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 2
    public function execute(Config $config, IO $io, Repository $repository, Config\Action $action)
38
    {
39 2
        $options = $action->getOptions();
40 2
        $book    = new RuleBook();
41 2
        $book->setRules(
42
            [
43 2
                new Rule\CapitalizeSubject(),
44 2
                new Rule\LimitSubjectLength($options->get('subjectLength', 50)),
45 2
                new Rule\NoPeriodOnSubjectEnd(),
46 2
                new Rule\UseImperativeMood(),
47 2
                new Rule\LimitBodyLineLength($options->get('bodyLineLength', 72)),
48 2
                new Rule\SeparateSubjectFromBodyWithBlankLine(),
49
            ]
50
        );
51
52 2
        $this->validate($book, $repository);
53 1
    }
54
}
55