Completed
Pull Request — master (#104)
by
unknown
07:23
created

TTaggable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 6
c 2
b 2
f 0
lcom 1
cbo 0
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTags() 0 4 1
A setTags() 0 5 1
A hasTag() 0 4 1
A hasTags() 0 9 3
1
<?php
2
namespace Nayjest\Grids\Components\Base;
3
4
5
trait TTaggable
6
{
7
    protected $tags = [];
8
9
    /**
10
     * @return array
11
     */
12
    public function getTags()
13
    {
14
        return $this->tags;
15
    }
16
17
    /**
18
     * @param array $tags
19
     * @return $this
20
     */
21
    public function setTags(array $tags)
22
    {
23
        $this->tags = $tags;
24
        return $this;
25
    }
26
27
    /**
28
     * @param string $tagName
29
     * @return bool
30
     */
31
    public function hasTag($tagName)
32
    {
33
        return in_array($tagName, $this->tags);
34
    }
35
36
    /**
37
     * @param array|string[] $tagNames
38
     * @return bool
39
     */
40
    public function hasTags(array $tagNames)
41
    {
42
        foreach ($tagNames as $tag) {
43
            if (!$this->hasTag($tag)) {
44
                return false;
45
            }
46
        }
47
        return true;
48
    }
49
}
50
51