Completed
Push — master ( 819e89...46ea75 )
by Thomas
10:56
created

TagsPart   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 76.47%

Importance

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

3 Methods

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