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

ExtensionPart::parseExtensions()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 7
cts 9
cp 0.7778
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 3.0987
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