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

QueryTrait::getResolutionTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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