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.
Completed
Push — master ( 560332...66e815 )
by Robert
11:59
created

InlineValidator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 66
ccs 14
cts 15
cp 0.9333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateAttribute() 0 8 2
A clientValidateAttribute() 0 13 3
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\validators;
9
10
/**
11
 * InlineValidator represents a validator which is defined as a method in the object being validated.
12
 *
13
 * The validation method must have the following signature:
14
 *
15
 * ```php
16
 * function foo($attribute, $params, $validator)
17
 * ```
18
 *
19
 * where `$attribute` refers to the name of the attribute being validated, while `$params` is an array representing the
20
 * additional parameters supplied in the validation rule. Parameter `$validator` refers to the related
21
 * [[InlineValidator]] object and is available since version 2.0.11.
22
 *
23
 * @author Qiang Xue <[email protected]>
24
 * @since 2.0
25
 */
26
class InlineValidator extends Validator
27
{
28
    /**
29
     * @var string|\Closure an anonymous function or the name of a model class method that will be
30
     * called to perform the actual validation. The signature of the method should be like the following:
31
     *
32
     * ```php
33
     * function foo($attribute, $params, $validator)
34
     * ```
35
     *
36
     * - `$attribute` is the name of the attribute to be validated;
37
     * - `$params` contains the value of [[params]] that you specify when declaring the inline validation rule;
38
     * - `$validator` is a reference to related [[InlineValidator]] object.
39
     */
40
    public $method;
41
    /**
42
     * @var mixed additional parameters that are passed to the validation method
43
     */
44
    public $params;
45
    /**
46
     * @var string|\Closure an anonymous function or the name of a model class method that returns the client validation code.
47
     * The signature of the method should be like the following:
48
     *
49
     * ```php
50
     * function foo($attribute, $params, $validator)
51
     * {
52
     *     return "javascript";
53
     * }
54
     * ```
55
     *
56
     * where `$attribute` refers to the attribute name to be validated.
57
     *
58
     * Please refer to [[clientValidateAttribute()]] for details on how to return client validation code.
59
     */
60
    public $clientValidate;
61
62
63
    /**
64
     * @inheritdoc
65
     */
66 1
    public function validateAttribute($model, $attribute)
67
    {
68 1
        $method = $this->method;
69 1
        if (is_string($method)) {
70 1
            $method = [$model, $method];
71 1
        }
72 1
        call_user_func($method, $attribute, $this->params, $this);
73 1
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78 1
    public function clientValidateAttribute($model, $attribute, $view)
79
    {
80 1
        if ($this->clientValidate !== null) {
81 1
            $method = $this->clientValidate;
82 1
            if (is_string($method)) {
83 1
                $method = [$model, $method];
84 1
            }
85
86 1
            return call_user_func($method, $attribute, $this->params, $this);
87
        } else {
88
            return null;
89
        }
90
    }
91
}
92