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 (#952)
by Henrique
05:29
created

LengthException::chooseTemplate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 4
nop 0
dl 0
loc 15
ccs 0
cts 8
cp 0
crap 20
rs 9.2
c 0
b 0
f 0
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
declare(strict_types=1);
13
14
namespace Respect\Validation\Exceptions;
15
16
class LengthException extends ValidationException
17
{
18
    const BOTH = 0;
19
    const LOWER = 1;
20
    const GREATER = 2;
21
    const EXACT = 3;
22
23
    public static $defaultTemplates = [
24
        self::MODE_DEFAULT => [
25
            self::BOTH => '{{name}} must have a length between {{minValue}} and {{maxValue}}',
26
            self::LOWER => '{{name}} must have a length greater than {{minValue}}',
27
            self::GREATER => '{{name}} must have a length lower than {{maxValue}}',
28
            self::EXACT => '{{name}} must have a length of {{maxValue}}',
29
        ],
30
        self::MODE_NEGATIVE => [
31
            self::BOTH => '{{name}} must not have a length between {{minValue}} and {{maxValue}}',
32
            self::LOWER => '{{name}} must not have a length greater than {{minValue}}',
33
            self::GREATER => '{{name}} must not have a length lower than {{maxValue}}',
34
            self::EXACT => '{{name}} must not have a length of {{maxValue}}',
35
        ],
36
    ];
37
38
    public function chooseTemplate()
39
    {
40
        if (!$this->getParam('minValue')) {
41
            return static::GREATER;
42
        }
43
44
        if (!$this->getParam('maxValue')) {
45
            return static::LOWER;
46
        }
47
48
        if ($this->getParam('minValue') == $this->getParam('maxValue')) {
49
            return self::EXACT;
50
        }
51
52
        return static::BOTH;
53
    }
54
}
55