Completed
Branch develop-3.0 (4fe777)
by Mohamed
11:06
created

UserRelations::issuesUpdatedBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Model;
13
14
/**
15
 * RelationTrait is trait class containing the relationship methods for the User model.
16
 *
17
 * @author Mohamed Alsharaf <[email protected]>
18
 *
19
 * @property static $this
20
 */
21
trait UserRelations
22
{
23
    /**
24
     * A user has one role (inverse relationship of Role::users).
25
     *
26
     * @return Relations\BelongsTo
27
     */
28
    public function role()
29
    {
30
        return $this->belongsTo('Tinyissue\Model\Role', 'role_id');
0 ignored issues
show
Bug introduced by
It seems like belongsTo() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
31
    }
32
33
    /**
34
     * User has many comments (One-many relationship of Comment::user).
35
     *
36
     * @return Relations\HasMany
37
     */
38
    public function comments()
39
    {
40
        return $this->hasMany('Tinyissue\Model\Project\Issue\Comment', 'created_by', 'id');
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
41
    }
42
43
    /**
44
     * Returns issues created by the user.
45
     *
46
     * @return Relations\HasMany
47
     */
48
    public function issuesCreatedBy()
49
    {
50
        return $this->hasMany('Tinyissue\Model\Project\Issue', 'created_by');
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
51
    }
52
53
    /**
54
     * Returns issues closed by the user.
55
     *
56
     * @return Relations\HasMany
57
     */
58
    public function issuesClosedBy()
59
    {
60
        return $this->hasMany('Tinyissue\Model\Project\Issue', 'closed_by');
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
61
    }
62
63
    /**
64
     * Returns issues updated by the user.
65
     *
66
     * @return Relations\HasMany
67
     */
68
    public function issuesUpdatedBy()
69
    {
70
        return $this->hasMany('Tinyissue\Model\Project\Issue', 'updated_by');
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
71
    }
72
73
    /**
74
     * User has many attachments (One-many relationship of Attachment::user).
75
     *
76
     * @return Relations\HasMany
77
     */
78
    public function attachments()
79
    {
80
        return $this->hasMany('Tinyissue\Model\Project\Issue\Attachment', 'uploaded_by');
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
81
    }
82
83
    /**
84
     * Returns all projects the user can access.
85
     *
86
     * @return Relations\HasMany
87
     */
88
    public function projects()
89
    {
90
        return $this
0 ignored issues
show
Bug introduced by
It seems like belongsToMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
91
            ->belongsToMany('Tinyissue\Model\Project', 'projects_users')
92
            ->orderBy('name');
93
    }
94
//
95
//    public function projectUsers()
96
//    {
97
//        return $this->belongsToMany(Project\User::class, 'users', 'user_id');
98
//    }
99
100
    /**
101
     * User has many issues assigned to (One-many relationship of Issue::assigned).
102
     *
103
     * @return Relations\HasMany
104
     */
105
    public function issues()
106
    {
107
        return $this->hasMany('Tinyissue\Model\Project\Issue', 'assigned_to');
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
108
    }
109
110
    /**
111
     * Returns all permission for the user.
112
     *
113
     * @return Relations\HasMany
114
     */
115
    public function permissions()
116
    {
117
        return $this->hasMany('\Tinyissue\Model\Role\Permission', 'role_id', 'role_id');
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
118
    }
119
120
//    abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null);
121
//
122
//    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
123
//
124
//    abstract public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null);
125
}
126