LimitTheTitleLengthTo69CharactersValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2016 Billie Thompson
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace PurpleBooth\GitLintValidators\Validator;
13
14
use PurpleBooth\GitLintValidators\Message;
15
use PurpleBooth\GitLintValidators\Status\LimitTheTitleLengthTo69CharactersStatus;
16
17
/**
18
 * This validator will check the title length is at most 69 characters long.
19
 *
20
 * @see     LimitTheTitleLengthTo69CharactersStatus
21
 */
22
class LimitTheTitleLengthTo69CharactersValidator implements Validator
23
{
24
    const CHARACTER_LIMIT = 69;
25
26
    /**
27
     * Check if a message passes a specific test, and return a status that identifies if it is or isn't.
28
     *
29
     * @param Message $message
30
     */
31
    public function validate(Message $message)
32
    {
33
        if ($message->getTitleLength() > self::CHARACTER_LIMIT) {
34
            $message->addStatus(new LimitTheTitleLengthTo69CharactersStatus());
35
        }
36
    }
37
}
38