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 ( 804d88...9de2aa )
by t
02:26
created

PHPUnit::checkAttribute()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 7
c 1
b 0
f 0
nc 3
nop 3
dl 0
loc 10
rs 10
1
<?php
2
/**
3
 * Class PHPUnit
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2017, icy2003
8
 */
9
10
namespace icy2003\php\iexts\yii2;
11
12
/**
13
 * PHPUnit 扩展
14
 *
15
 * yii2 模型的单元测试断言快捷方式
16
 */
17
class PHPUnit extends \Codeception\Test\Unit
18
{
19
    /**
20
     * 断言 True
21
     *
22
     * @param yii\base\Model $model 模型对象
23
     * @param mixed $attributes
24
     *
25
     * @return void
26
     */
27
    public static function true($model, $attributes = null)
28
    {
29
        parent::assertTrue($model->validate($attributes), implode($model->getFirstErrors()));
30
    }
31
32
    /**
33
     * 断言 False
34
     *
35
     * @param yii\base\Model $model 模型对象
36
     * @param mixed $attributes
37
     *
38
     * @return void
39
     */
40
    public static function false($model, $attributes = null)
41
    {
42
        parent::assertFalse($model->validate($attributes), implode($model->getFirstErrors()));
43
    }
44
45
    /**
46
     * 断言属性
47
     *
48
     * @param yii\base\Model $model 模型对象
49
     * @param [type] $attribute 属性
50
     * @param [type] $array 格式:[错误的属性值,正确的属性值],正确的属性可以不要
51
     *
52
     * @return void
53
     */
54
    public static function checkAttribute($model, $attribute, $array)
55
    {
56
        if (2 >= count($array) && isset($array[0])) {
57
            $model->$attribute = $array[0];
58
            static::false($model, $attribute);
59
            if (isset($array[1])) {
60
                $model->$attribute = $array[1];
61
            }
62
        } else {
63
            throw new \Exception('数组 0 位元素表示错误的属性值,1 位元素表示正确的属性值');
64
        }
65
    }
66
}
67