CommentQuery::withoutDeleted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 1 Features 1
Metric Value
c 4
b 1
f 1
dl 0
loc 9
ccs 0
cts 4
cp 0
rs 9.6666
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * CommentQuery.php
4
 * @author Revin Roman
5
 * @link https://rmrevin.ru
6
 */
7
8
namespace rmrevin\yii\module\Comments\models\queries;
9
10
use rmrevin\yii\module\Comments;
11
12
/**
13
 * Class CommentQuery
14
 * @package rmrevin\yii\module\Comments\models\queries
15
 *
16
 * @method \rmrevin\yii\module\Comments\models\Comment|array|null one($db = null)
17
 * @method \rmrevin\yii\module\Comments\models\Comment[]|array all($db = null)
18
 */
19
class CommentQuery extends \yii\db\ActiveQuery
20
{
21
22
    /**
23
     * @param integer|array $id
24
     * @return static
25
     */
26
    public function byId($id)
27
    {
28
        $this->andWhere(['id' => $id]);
29
30
        return $this;
31
    }
32
33
    /**
34
     * @param string|array $entity
35
     * @return static
36
     */
37
    public function byEntity($entity)
38
    {
39
        $this->andWhere(['entity' => $entity]);
40
41
        return $this;
42
    }
43
44
    /**
45
     * @return static
46
     */
47
    public function withoutDeleted()
48
    {
49
        /** @var Comments\models\Comment $CommentModel */
50
        $CommentModel = \Yii::createObject(Comments\Module::instance()->model('comment'));
51
52
        $this->andWhere(['deleted' => $CommentModel::NOT_DELETED]);
53
54
        return $this;
55
    }
56
}
57