Completed
Push — master ( 42128a...09a28f )
by vistart
19:27
created

MemberQuery::organization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 1
cc 1
eloc 2
nc 1
nop 1
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\organization\queries;
14
15
use rhosocial\base\models\queries\BaseBlameableQuery;
16
use rhosocial\user\User;
17
use rhosocial\organization\Member;
18
use rhosocial\organization\Organization;
19
20
/**
21
 * Member Query.
22
 *
23
 * @version 1.0
24
 * @author vistart <[email protected]>
25
 */
26
class MemberQuery extends BaseBlameableQuery
27
{
28
    public $modelClass = Member::class;
29
30
    /**
31
     * Specify user.
32
     * @param User $user
33
     * @return static
34
     */
35
    public function user($user)
36
    {
37
        $model = $this->noInitModel;
38
        /* @var $model Member */
39
        if (!is_string($model->memberAttribute) || empty($model->memberAttribute)) {
40
            return $this;
41
        }
42
        if ($user instanceof BaseUserModel) {
0 ignored issues
show
Bug introduced by
The class rhosocial\organization\queries\BaseUserModel does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
43
            $user = $user->getGUID();
44
        }
45
        return $this->andWhere([$model->memberAttribute => $user]);
46
    }
47
48
    /**
49
     * Specify organization.
50
     * Alias of `createdBy` method.
51
     * @param Organization $organization
52
     * @return static
53
     */
54
    public function organization($organization)
55
    {
56
        return $this->createdBy($organization);
57
    }
58
}
59