RelationTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
c 1
b 1
f 0
lcom 1
cbo 0
dl 0
loc 74
ccs 12
cts 14
cp 0.8571
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A issue() 0 4 1
A user() 0 4 1
A assignTo() 0 4 1
A activity() 0 4 1
A comment() 0 4 1
A project() 0 4 1
A note() 0 4 1
belongsTo() 0 1 ?
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\Traits\User\Activity;
13
14
use Illuminate\Database\Eloquent\Relations;
15
16
/**
17
 * RelationTrait is trait class containing the relationship method for the User\Activity model.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 *
21
 * @property static $this
22
 */
23
trait RelationTrait
24
{
25
    /**
26
     * Returns the project issue this activity is belongs to by the item_id, which can hold the issue id.
27
     *
28
     * @return Relations\BelongsTo
29
     */
30 7
    public function issue()
31
    {
32 7
        return $this->belongsTo('Tinyissue\Model\Project\Issue', 'item_id');
33
    }
34
35
    /**
36
     * Returns the user this activity is belongs to.
37
     *
38
     * @return Relations\BelongsTo
39
     */
40 13
    public function user()
41
    {
42 13
        return $this->belongsTo('\Tinyissue\Model\User', 'user_id');
43
    }
44
45
    /**
46
     * Returns the user that was assigned to the issue. Only for reassign activity.
47
     *
48
     * @return Relations\BelongsTo
49
     */
50 13
    public function assignTo()
51
    {
52 13
        return $this->belongsTo('\Tinyissue\Model\User', 'action_id');
53
    }
54
55
    /**
56
     * User activity has one activity type.
57
     *
58
     * @return Relations\BelongsTo
59
     */
60 13
    public function activity()
61
    {
62 13
        return $this->belongsTo('Tinyissue\Model\Activity', 'type_id');
63
    }
64
65
    /**
66
     * Returns the comment this activity belongs to if any.
67
     *
68
     * @return Relations\BelongsTo
69
     */
70 13
    public function comment()
71
    {
72 13
        return $this->belongsTo('Tinyissue\Model\Project\Issue\Comment', 'action_id');
73
    }
74
75
    /**
76
     * Returns the project his activity belongs to.
77
     *
78
     * @return Relations\BelongsTo
79
     */
80
    public function project()
81
    {
82
        return $this->belongsTo('Tinyissue\Model\Project', 'parent_id');
83
    }
84
85
    /**
86
     * Returns the note this activity belongs to if any.
87
     *
88
     * @return Relations\BelongsTo
89
     */
90 7
    public function note()
91
    {
92 7
        return $this->belongsTo('\Tinyissue\Model\Project\Note', 'action_id');
93
    }
94
95
    abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null);
96
}
97