GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BetweenValidator   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C validateField() 0 29 8
1
<?php
2
3
/**
4
 * This file is part of the PHPMongo package.
5
 *
6
 * (c) Dmytro Sokil <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sokil\Mongo\Validator;
13
14
use Sokil\Mongo\Structure;
15
16
/**
17
 * Validates value between specified
18
 *
19
 * @author Dmytro Sokil <[email protected]>
20
 */
21
class BetweenValidator extends \Sokil\Mongo\Validator
22
{
23
24
    public function validateField(Structure $document, $fieldName, array $params)
25
    {
26
        $value = $document->get($fieldName);
27
        if (!$value) {
28
            return;
29
        }
30
31
        if (!isset($params['min'])) {
32
            throw new Exception('Minimum value of range not specified');
33
        }
34
        
35
        if (!isset($params['max'])) {
36
            throw new Exception('Maximum value of range not specified');
37
        }
38
        
39
        if ($value < $params['min']) {
40
            if (empty($params['minMessage'])) {
41
                $params['minMessage'] = 'Field "' . $fieldName . '" less than minimal value of range in ' . get_called_class();
42
            }
43
            $document->addError($fieldName, $this->getName(), $params['minMessage']);
44
        }
45
        
46
        if ($value > $params['max']) {
47
            if (empty($params['maxMessage'])) {
48
                $params['maxMessage'] = 'Field "' . $fieldName . '" less than minimal value of range in ' . get_called_class();
49
            }
50
            $document->addError($fieldName, $this->getName(), $params['maxMessage']);
51
        }
52
    }
53
}
54