BaseUserRelationQuery   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 77.78%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 4
c 7
b 0
f 0
lcom 1
cbo 2
dl 0
loc 28
ccs 7
cts 9
cp 0.7778
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A groups() 0 14 4
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link http://vistart.name/
9
 * @copyright Copyright (c) 2016 vistart
10
 * @license http://vistart.name/license/
11
 */
12
13
namespace vistart\Models\queries;
14
15
use vistart\Models\models\BaseUserRelationModel;
16
use vistart\Models\traits\MutualQueryTrait;
17
18
/**
19
 * Description of BaseUserRelationQuery
20
 *
21
 * Note: You must specify $modelClass property, and the class must be the subclass
22
 * of `\vistart\Models\models\BaseUserRelationModel`.
23
 * @version 2.0
24
 * @author vistart <[email protected]>
25
 */
26
class BaseUserRelationQuery extends BaseBlameableQuery
27
{
28
    use MutualQueryTrait;
29
30
    /**
31
     * Specify groups.
32
     * This method will be skipped if not enable the group features (`$multiBlamesAttribute = false`).
33
     * @param string|array $groups the guid of group If string, or guid array of
34
     * groups if array. If you want to get ungrouped relation(s), please assign
35
     * empty array, or if you do not want to delimit group(s), please do not
36
     * access this method, or assign null.
37
     * @return static $this
38
     */
39 1
    public function groups($groups = [])
40
    {
41 1
        if ($groups === null) {
42
            return $this;
43
        }
44 1
        $model = $this->noInitModel;
45 1
        if (!is_string($model->multiBlamesAttribute)) {
46
            return $this;
47
        }
48 1
        if (empty($groups)) {
49 1
            return $this->andWhere([$model->multiBlamesAttribute => BaseUserRelationModel::getEmptyGroupJson()]);
0 ignored issues
show
Bug introduced by
The method getEmptyGroupJson() does not seem to exist on object<vistart\Models\mo...\BaseUserRelationModel>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
        }
51 1
        return $this->andWhere(['or like', $model->multiBlamesAttribute, $groups]);
52
    }
53
}
54