Completed
Pull Request — master (#6)
by Guilh
02:50
created

License::merge()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
namespace gossi\swagger;
3
4
use gossi\swagger\parts\ExtensionPart;
5
use gossi\swagger\parts\UrlPart;
6
use phootwork\collection\CollectionUtils;
7
use phootwork\lang\Arrayable;
8
9
class License extends AbstractModel implements Arrayable {
10
11
	use UrlPart;
12
	use ExtensionPart;
13
14
	/** @var string */
15
	private $name;
16
17 10
	public function __construct($contents = []) {
18 10
		$this->merge($contents);
19 10
	}
20
21 10
	public function merge($contents, $strategy = self::PREFER_ORIGINAL) {
22 10
		$data = CollectionUtils::toMap($contents);
23
24 10
		$this->mergeFields($this->name, $data->get('name'), $strategy);
25
26
		// extensions
27 10
		$this->parseUrl($data);
28 10
		$this->parseExtensions($data);
29 10
	}
30
31 7
	public function toArray() {
32 7
		return $this->export('name', 'url');
33
	}
34
35
	/**
36
	 *
37
	 * @return string
38
	 */
39 1
	public function getName() {
40 1
		return $this->name;
41
	}
42
43
	/**
44
	 *
45
	 * @param string $name
46
	 * @return $this
47
	 */
48 1
	public function setName($name) {
49 1
		$this->name = $name;
50 1
		return $this;
51
	}
52
53
}
54