Completed
Push — master ( 04b0bc...360258 )
by Nate
05:02 queued 03:42
created

Attributes::status()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/domains/license
6
 * @link       https://www.flipboxfactory.com/software/domains/
7
 */
8
9
namespace flipbox\domains\db\traits;
10
11
use craft\helpers\Db;
12
use yii\db\Expression;
13
14
trait Attributes
15
{
16
    /**
17
     * @var string|string[]|false|null The domain(s). Prefix with "not " to exclude them.
18
     */
19
    public $domain;
20
21
    /**
22
     * @var string|string[]|false|null The status(es). Prefix with "not " to exclude them.
23
     */
24
    public $status;
25
26
    /**
27
     * Adds an additional WHERE condition to the existing one.
28
     * The new condition and the existing one will be joined using the `AND` operator.
29
     * @param string|array|Expression $condition the new WHERE condition. Please refer to [[where()]]
30
     * on how to specify this parameter.
31
     * @param array $params the parameters (name => value) to be bound to the query.
32
     * @return $this the query object itself
33
     * @see where()
34
     * @see orWhere()
35
     */
36
    abstract public function andWhere($condition, $params = []);
37
38
    /**
39
     * @param $value
40
     * @return static
41
     */
42
    public function domain($value)
43
    {
44
        $this->domain = $value;
45
        return $this;
46
    }
47
48
    /**
49
     * @param $value
50
     * @return static
51
     */
52
    public function status($value)
53
    {
54
        $this->status = $value;
55
        return $this;
56
    }
57
58
    /**
59
     * Apply attribute conditions
60
     */
61
    protected function applyConditions()
62
    {
63
        if ($this->domain !== null) {
64
            $this->andWhere(Db::parseParam('domain', $this->domain));
65
        }
66
67
        if ($this->status !== null) {
68
            $this->andWhere(Db::parseParam('domain', $this->status));
69
        }
70
    }
71
}
72