Completed
Push — master ( 14d652...6f6b3d )
by vistart
05:22
created

BaseRedisEntityQuery::range()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 4
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
use rhosocial\base\models\traits\EntityQueryTrait;
16
17
/**
18
 * Description of BaseRedisEntityQuery
19
 *
20
 * @version 1.0
21
 * @author vistart <[email protected]>
22
 */
23
class BaseRedisEntityQuery extends \yii\redis\ActiveQuery
24
{
25
    use EntityQueryTrait;
26
    
27 3
    protected static function range($query, $attribute, $start = null, $end = null)
28
    {
29 3
        if (!isset($attribute, $start, $end)) {
30 3
            throw new \yii\db\Exception("`attribute`, `start` and `end` must be specified.");
31 3
        }
32
        return $query->andWhere(['between', $attribute, $start, $end]);
33
    }
34
35
    public function init()
36
    {
37
        $this->buildNoInitModel();
38
        parent::init();
39
    }
40
}
41