TokenActiveQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 2
cbo 6
dl 0
loc 40
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 12 1
A prepare() 0 8 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\patron\queries;
10
11
use flipbox\craft\ember\queries\ActiveQuery;
12
use flipbox\craft\ember\queries\AuditAttributesTrait;
13
use flipbox\craft\ember\queries\UserAttributeTrait;
14
use flipbox\patron\records\Token;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class TokenActiveQuery extends ActiveQuery
21
{
22
    use TokenAttributesTrait,
23
        TokenProviderAttributeTrait,
24
        UserAttributeTrait,
25
        AuditAttributesTrait;
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function init()
31
    {
32
        $this->orderBy = [
33
            Token::tableAlias() . '.enabled' => SORT_DESC,
34
            Token::tableAlias() . '.dateExpires' => SORT_DESC,
35
            Token::tableAlias() . '.dateUpdated' => SORT_DESC
36
        ];
37
38
        $this->from = [Token::tableName() . ' ' . Token::tableAlias()];
39
40
        parent::init();
41
    }
42
43
    /*******************************************
44
     * FIXED ORDER
45
     *******************************************/
46
47
    /**
48
     * @inheritdoc
49
     * @throws \ReflectionException
50
     */
51
    public function prepare($builder)
52
    {
53
        $this->applyTokenConditions();
54
        $this->applyProviderConditions();
55
        $this->applyAuditAttributeConditions();
56
57
        return parent::prepare($builder);
58
    }
59
}
60