Tagging   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 6
c 1
b 0
f 1
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setTags() 0 4 1
A hasTags() 0 3 1
A getTags() 0 3 1
1
<?php
2
/**
3
 * Tagging support
4
 * User: moyo
5
 * Date: 21/11/2017
6
 * Time: 3:34 PM
7
 */
8
9
namespace Carno\Net\Chips\Endpoint;
10
11
trait Tagging
12
{
13
    /**
14
     * @var array
15
     */
16
    private $tags = [];
17
18
    /**
19
     * @param string ...$tags
20
     * @return bool
21
     */
22
    public function hasTags(string ...$tags) : bool
23
    {
24
        return count(array_intersect($this->tags, $tags)) === count($tags);
25
    }
26
27
    /**
28
     * @param string ...$tags
29
     * @return self
30
     */
31
    public function setTags(string ...$tags) : self
32
    {
33
        $this->tags = array_unique(array_merge($this->tags, $tags));
34
        return $this;
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public function getTags() : array
41
    {
42
        return $this->tags;
43
    }
44
}
45