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 (#1094)
by Henrique
04:43
created

LengthException::chooseTemplate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.0312

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
cc 4
nc 4
nop 0
crap 4.0312
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
/**
17
 * @author Alexandre Gomes Gaigalas <[email protected]>
18
 * @author Danilo Correa <[email protected]>
19
 * @author Henrique Moody <[email protected]>
20
 */
21
final class LengthException extends ValidationException
22
{
23
    public const BOTH = 'both';
24
    public const LOWER = 'lower';
25
    public const GREATER = 'greater';
26
    public const EXACT = 'exact';
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public static $defaultTemplates = [
32
        self::MODE_DEFAULT => [
33
            self::BOTH => '{{name}} must have a length between {{minValue}} and {{maxValue}}',
34
            self::LOWER => '{{name}} must have a length greater than {{minValue}}',
35
            self::GREATER => '{{name}} must have a length lower than {{maxValue}}',
36
            self::EXACT => '{{name}} must have a length of {{maxValue}}',
37
        ],
38
        self::MODE_NEGATIVE => [
39
            self::BOTH => '{{name}} must not have a length between {{minValue}} and {{maxValue}}',
40
            self::LOWER => '{{name}} must not have a length greater than {{minValue}}',
41
            self::GREATER => '{{name}} must not have a length lower than {{maxValue}}',
42
            self::EXACT => '{{name}} must not have a length of {{maxValue}}',
43
        ],
44
    ];
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 10
    protected function chooseTemplate(): string
50
    {
51 10
        if (!$this->getParam('minValue')) {
52 1
            return static::GREATER;
53
        }
54
55 10
        if (!$this->getParam('maxValue')) {
56 1
            return static::LOWER;
57
        }
58
59 10
        if ($this->getParam('minValue') == $this->getParam('maxValue')) {
60
            return self::EXACT;
61
        }
62
63 10
        return static::BOTH;
64
    }
65
}
66