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

CapitalizeSubject   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
c 0
b 0
f 0
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 7 2
A __construct() 0 3 1
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
use SebastianFeldmann\Git\CommitMessage;
15
16
/**
17
 * Class CapitalizeSubject
18
 *
19
 * @package CaptainHook
20
 * @author  Sebastian Feldmann <[email protected]>
21
 * @link    https://github.com/captainhookphp/captainhook
22
 * @since   Class available since Release 0.9.0
23
 */
24
class CapitalizeSubject extends Base
25
{
26
    /**
27 9
     * Constructor
28
     */
29 9
    public function __construct()
30 9
    {
31
        $this->hint = 'Subject line has to start with an upper case letter';
32
    }
33
34
    /**
35
     * Check if commit message starts with upper case letter
36
     *
37
     * @param  \SebastianFeldmann\Git\CommitMessage $msg
38 9
     * @return bool
39
     */
40 9
    public function pass(CommitMessage $msg): bool
41 8
    {
42 8
        if (!$msg->isEmpty()) {
43
            $firstLetter = substr($msg->getSubject(), 0, 1);
44 1
            return $firstLetter === strtoupper($firstLetter);
45
        }
46
        return false;
47
    }
48
}
49