validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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\SoftLimitTheTitleLengthTo50CharactersStatus;
16
17
/**
18
 * This validator will check the subject is not longer than 50 characters.
19
 *
20
 * @see     SoftLimitTheTitleLengthTo50CharactersStatus
21
 */
22
class SoftLimitTheTitleLengthTo50CharactersValidator implements Validator
23
{
24
    const CHARACTER_LIMIT = 50;
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 SoftLimitTheTitleLengthTo50CharactersStatus());
35
        }
36
    }
37
}
38