Completed
Pull Request — master (#6)
by Guilh
04:05
created

ItemsPart   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
c 3
b 1
f 0
lcom 1
cbo 2
dl 0
loc 24
ccs 5
cts 10
cp 0.5
rs 10
1
<?php
2
3
namespace gossi\swagger\parts;
4
5
use gossi\swagger\Items;
6
use gossi\swagger\util\MergeHelper;
7
use phootwork\collection\Map;
8
9
trait ItemsPart {
10
11
	/** @var */
12
	private $items;
13 9
14 9
	private function parseItems(Map $data) {
15 6
		if ($data->has('items')) {
16 6
			$this->items = new Items($data->get('items'));
17 9
		}
18
	}
19
20
	private function mergeItems(static $model, $overwrite = false) {
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STATIC, expecting T_VARIABLE
Loading history...
21
		if (null === $this->items) {
22
			$this->items = clone $model->items;
23
		} elseif (null !== $model->items) {
24
			$this->items->merge($model->items, $overwrite);
25
		}
26
	}
27
28
	/**
29
	 * Returns the items
30
	 *
31
	 * @return Items
32
	 */
33
	public function getItems() {
34
		if ($this->items === null) {
35
			$this->items = new Items();
36
		}
37
38
		return $this->items;
39
	}
40
}
41