Cancelled
Push — master ( a8b464...2fc3a5 )
by Billie
06:55
created

LimitTheBodyWrapLengthTo72CharactersValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace PurpleBooth\GitGitHubLint\Validator;
6
7
use PurpleBooth\GitGitHubLint\Message;
8
use PurpleBooth\GitGitHubLint\Status\LimitTheBodyWrapLengthTo72CharactersStatus;
9
use PurpleBooth\GitGitHubLint\Status\Status;
10
use PurpleBooth\GitGitHubLint\Status\SuccessStatus;
11
12
/**
13
 * This validator will check the body width is 72 characters wide at the most
14
 *
15
 * @see     LimitTheBodyWrapLengthTo72CharactersStatus
16
 * @see     SuccessStatus
17
 *
18
 * @package PurpleBooth\GitGitHubLint\Validator
19
 */
20
class LimitTheBodyWrapLengthTo72CharactersValidator implements Validator
21
{
22
    const WRAP_LIMIT = 72;
23
24
    /**
25
     * Check if a message passes a specific test, and return a status that identifies if it is or isn't
26
     *
27
     * @param Message $message
28
     *
29
     * @return Status
30
     */
31
    public function validate(Message $message) : Status
32
    {
33
        if ($message->getBodyWrapLength() > self::WRAP_LIMIT) {
34
            return new LimitTheBodyWrapLengthTo72CharactersStatus();
35
        }
36
37
        return new SuccessStatus();
38
    }
39
}
40