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.

IpValidator::validateField()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
rs 9.2
cc 4
eloc 9
nc 4
nop 3
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
class IpValidator extends \Sokil\Mongo\Validator
17
{
18
    public function validateField(Structure $document, $fieldName, array $params)
19
    {
20
        $value = $document->get($fieldName);
21
        
22
        // check only if set
23
        if (!$value) {
24
            return;
25
        }
26
27
        // check if url valid
28
        if (false !== filter_var($value, FILTER_VALIDATE_IP)) {
29
            return;
30
        }
31
        
32
        if (!isset($params['message'])) {
33
            $params['message'] = 'Value of field "' . $fieldName . '" is not valid IP address in model ' . get_called_class();
34
        }
35
36
        $document->addError($fieldName, $this->getName(), $params['message']);
37
    }
38
}
39