Completed
Push — master ( 087102...36165a )
by vistart
10:17
created

BaseUserQuery::active()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\base\models\queries;
14
15
/**
16
 * Description of BaseUserQuery
17
 *
18
 * @version 1.0
19
 * @author vistart <[email protected]>
20
 */
21
class BaseUserQuery extends BaseEntityQuery
22
{
23
24
    /**
25
     * Specify active status.
26
     * @param integer $active
27
     * @return static
28
     */
29 2
    public function active($active)
30
    {
31 2
        $model = $this->noInitModel;
32 2
        if (!is_string($model->statusAttribute)) {
33
            return $this;
34
        }
35 2
        return $this->andWhere([$model->statusAttribute => $active]);
36
    }
37
38
    /**
39
     * Specify source.
40
     * @param null|string|array $source
41
     * @return static
42
     */
43 1
    public function source($source = null)
44
    {
45 1
        $model = $this->noInitModel;
46 1
        if (!is_string($model->sourceAttribute)) {
47
            return $this;
48
        }
49 1
        if (!is_string($source)) {
50
            $modelClass = $this->modelClass;
51
            $source = $modelClass::$sourceSelf;
52
        }
53 1
        return $this->andWhere([$model->sourceAttribute => $source]);
54
    }
55
}
56