Passed
Push — master ( 69774c...de7969 )
by Sebastian
02:46
created

UseImperativeMood   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 16
c 1
b 0
f 0
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 22 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\Rule;
13
14
/**
15
 * Class UseImperativeMood
16
 *
17
 * @package CaptainHook
18
 * @author  Sebastian Feldmann <[email protected]>
19
 * @link    https://github.com/captainhookphp/captainhook
20
 * @since   Class available since Release 0.9.0
21
 */
22
class UseImperativeMood extends Blacklist
23
{
24
    /**
25
     * Constructor
26
     *
27 11
     * @param bool $checkOnlyBeginning
28
     */
29 11
    public function __construct(bool $checkOnlyBeginning = false)
30 11
    {
31 11
        parent::__construct(false);
32
        $this->hint = 'Subject should be written in imperative mood';
33 11
        $this->setSubjectBlacklist(
34
            [
35
                'added',
36
                'changed',
37
                'created',
38
                'deleted',
39
                'fixed',
40
                'reformatted',
41
                'removed',
42
                'updated',
43
                'uploaded'
44 11
            ]
45
        );
46
47 4
        if ($checkOnlyBeginning) {
48
            // overwrite the detection logic to only check the beginning og the string
49
            $this->stringDetection = function (string $content, string $term): bool {
50 11
                return strpos($content, $term) === 0;
51
            };
52
        }
53
    }
54
}
55