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

ExternalDocs::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
namespace gossi\swagger;
3
4
use gossi\swagger\parts\DescriptionPart;
5
use gossi\swagger\parts\ExtensionPart;
6
use gossi\swagger\parts\UrlPart;
7
use phootwork\collection\CollectionUtils;
8
use phootwork\lang\Arrayable;
9
10
class ExternalDocs extends AbstractModel implements Arrayable {
11
12
	use DescriptionPart;
13
	use UrlPart;
14
	use ExtensionPart;
15
16 12
	public function __construct($contents = []) {
17 12
		$this->parse($contents);
18 12
	}
19
20 12
	private function parse($contents = []) {
21 12
		$data = CollectionUtils::toMap($contents);
22
23
		// parts
24 12
		$this->parseDescription($data);
25 12
		$this->parseUrl($data);
26 12
		$this->parseExtensions($data);
27 12
	}
28
29 10
	/**
30 10
	 * {@inheritdoc}
31
	 */
32
	public function merge(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...
33
		$this->mergeDescription($model, $overwrite);
34
		$this->mergeUrl($model, $overwrite);
35
		$this->mergeExtensions($model, $overwrite);
36
	}
37
38
	public function toArray() {
39
		return $this->export('description', 'url');
40
	}
41
42
}
43