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

ExtensionPart   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 81.82%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 24
ccs 9
cts 11
cp 0.8182
rs 10
1
<?php
2
namespace gossi\swagger\parts;
3
4
use gossi\swagger\util\MergeHelper;
5
use phootwork\collection\Map;
6
use phootwork\lang\Text;
7
8
trait ExtensionPart {
9
10
	private $extensions;
11 12
12 12
	private function parseExtensions(Map $data) {
13
		$this->extensions = new Map();
14 12
15 6
		foreach ($data as $k => $v) {
16 6
			$key = new Text($k);
17
			if ($key->startsWith('x-')) {
18
				$this->extensions->set($key->substring(2), $v);
19 12
			}
20 12
		}
21
	}
22
23
	private function mergeExtensions(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...
24
		MergeHelper::mergeFields($this->extensions, $model->description, $overwrite);
25
	}
26
27 11
	/**
28 11
	 * Returns extensions
29
	 *
30
	 * @return Map
31
	 */
32
	public function getExtensions() {
33
		return $this->extensions;
34
	}
35
}
36