TaggableTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTags() 0 3 1
A addTag() 0 4 1
A hasTag() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Habemus\Definition\Tag;
5
6
trait TaggableTrait
7
{
8
9
    /**
10
     * @var array
11
     */
12
    protected $tags = [];
13
14
    public function addTag(string $tag)
15
    {
16
        $this->tags[] = $tag;
17
        return $this;
18
    }
19
20
    public function hasTag(string $tag): bool
21
    {
22
        return in_array($tag, $this->tags);
23
    }
24
25
    public function getTags(): array
26
    {
27
        return $this->tags;
28
    }
29
}
30