Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#893)
by Islam
06:18
created

LengthException::chooseTemplate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 0
crap 4
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Exceptions;
13
14
class LengthException extends ValidationException
15
{
16
    const BOTH = 0;
17
    const LOWER = 1;
18
    const GREATER = 2;
19
    const EXACT = 3;
20
21
    public static $defaultTemplates = [
22
        self::MODE_DEFAULT => [
23
            self::BOTH => '{{name}} must have a length between {{minValue}} and {{maxValue}}',
24
            self::LOWER => '{{name}} must have a length greater than {{minValue}}',
25
            self::GREATER => '{{name}} must have a length lower than {{maxValue}}',
26
            self::EXACT => '{{name}} must have a length of {{maxValue}}',
27
        ],
28
        self::MODE_NEGATIVE => [
29
            self::BOTH => '{{name}} must not have a length between {{minValue}} and {{maxValue}}',
30
            self::LOWER => '{{name}} must not have a length greater than {{minValue}}',
31
            self::GREATER => '{{name}} must not have a length lower than {{maxValue}}',
32
            self::EXACT => '{{name}} must not have a length of {{maxValue}}',
33
        ],
34
    ];
35
36 16
    public function chooseTemplate()
37
    {
38 16
        if (!$this->getParam('minValue')) {
39 1
            return static::GREATER;
40
        }
41
42 16
        if (!$this->getParam('maxValue')) {
43 3
            return static::LOWER;
44
        }
45
46 16
        if ($this->getParam('minValue') == $this->getParam('maxValue')) {
47 1
            return self::EXACT;
48
        }
49
50 15
        return static::BOTH;
51
    }
52
}
53