Completed
Pull Request — master (#3)
by Guilh
02:22
created

TagsPart   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 76.47%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 1
cbo 3
dl 0
loc 36
ccs 13
cts 17
cp 0.7647
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parseTags() 0 7 2
A getTags() 0 4 1
A exportTags() 0 13 3
1
<?php
2
3
namespace gossi\swagger\parts;
4
5
use phootwork\collection\Map;
6
use phootwork\collection\ArrayList;
7
use gossi\swagger\Tag;
8
9
trait TagsPart
10
{
11
    private $tags;
12
13 12
    private function parseTags(Map $data)
14
    {
15 12
        $this->tags = new ArrayList();
16 12
        foreach ($data->get('tags', []) as $t) {
17 1
            $this->tags->add(new Tag($t));
18 12
        }
19 12
    }
20
21
    /**
22
     * Return tags.
23
     *
24
     * @return ArrayList
25
     */
26
    public function getTags()
27
    {
28
        return $this->tags;
29
    }
30
31 7
    protected function exportTags()
32
    {
33 7
        $out = [];
34 7
        foreach ($this->tags as $tag) {
35 1
            if ($tag->isObject()) {
36
                $out[] = $tag->toArray();
37
            } else {
38 1
                $out[] = $tag->getName();
39
            }
40 7
        }
41
42 7
        return $out;
43
    }
44
}
45