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

License   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 5
c 5
b 1
f 0
lcom 1
cbo 5
dl 0
loc 45
ccs 16
cts 16
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A toArray() 0 3 1
A getName() 0 3 1
A setName() 0 4 1
A merge() 0 9 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