Completed
Push — develop ( 3a03d5...8f64a0 )
by Mohamed
07:49
created

QueryTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
c 4
b 1
f 0
lcom 1
cbo 0
dl 0
loc 46
ccs 0
cts 10
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatusTag() 0 4 1
A getTypeTag() 0 4 1
A getResolutionTag() 0 4 1
A getTagOfGroup() 0 6 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\Project\Issue;
13
14
use Illuminate\Database\Eloquent;
15
use Illuminate\Database\Eloquent\Relations;
16
use Tinyissue\Model\Tag;
17
18
/**
19
 * QueryTrait is trait class containing the database queries methods for the Project|Issue model.
20
 *
21
 * @author Mohamed Alsharaf <[email protected]>
22
 *
23
 * @method Relations\BelongsToMany tags()
24
 */
25
trait QueryTrait
26
{
27
    /**
28
     * Returns the status tag
29
     *
30
     * @return Tag
31
     */
32
    public function getStatusTag()
33
    {
34
        return $this->getTagOfGroup(Tag::GROUP_STATUS);
35
    }
36
37
    /**
38
     * Returns the type tag
39
     *
40
     * @return Tag
41
     */
42
    public function getTypeTag()
43
    {
44
        return $this->getTagOfGroup(Tag::GROUP_TYPE);
45
    }
46
47
    /**
48
     * Returns the resolution tag
49
     *
50
     * @return Tag
51
     */
52
    public function getResolutionTag()
53
    {
54
        return $this->getTagOfGroup(Tag::GROUP_RESOLUTION);
55
    }
56
57
    /**
58
     * Return tag by it group name.
59
     *
60
     * @param string $group
61
     *
62
     * @return Tag
63
     */
64
    protected function getTagOfGroup($group)
65
    {
66
        return $this->tags
0 ignored issues
show
Bug introduced by
The property tags does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
67
            ->where('parent.name', $group)
68
            ->first();
69
    }
70
}
71