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

Contact   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 9
c 4
b 1
f 0
lcom 1
cbo 4
dl 0
loc 87
ccs 27
cts 27
cp 1
rs 10

9 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 getUrl() 0 3 1
A setUrl() 0 4 1
A getEmail() 0 3 1
A setEmail() 0 4 1
A merge() 0 10 1
1
<?php
2
namespace gossi\swagger;
3
4
use gossi\swagger\parts\ExtensionPart;
5
use phootwork\collection\CollectionUtils;
6
use phootwork\lang\Arrayable;
7
8
class Contact extends AbstractModel implements Arrayable {
9
10
	use ExtensionPart;
11
12
	/** @var string */
13
	private $name;
14
15
	/** @var string */
16
	private $url;
17
18
	/** @var string */
19
	private $email;
20
21 10
	public function __construct($contents = []) {
22 10
		$this->merge($contents);
23 10
	}
24
25 10
	public function merge($contents, $strategy = self::PREFER_ORIGINAL) {
26 10
		$data = CollectionUtils::toMap($contents);
27
28 10
		$this->mergeFields($this->name, $data->get('name'), $strategy);
29 10
		$this->mergeFields($this->url, $data->get('url'), $strategy);
30 10
		$this->mergeFields($this->email, $data->get('email'), $strategy);
31
32
		// extensions
33 10
		$this->parseExtensions($data);
34 10
	}
35
36 7
	public function toArray() {
37 7
		return $this->export('name', 'url', 'email');
38
	}
39
40
	/**
41
	 *
42
	 * @return string
43
	 */
44 1
	public function getName() {
45 1
		return $this->name;
46
	}
47
48
	/**
49
	 *
50
	 * @param string $name
51
	 * @return $this
52
	 */
53 1
	public function setName($name) {
54 1
		$this->name = $name;
55 1
		return $this;
56
	}
57
58
	/**
59
	 *
60
	 * @return string
61
	 */
62 1
	public function getUrl() {
63 1
		return $this->url;
64
	}
65
66
	/**
67
	 *
68
	 * @param string $url
69
	 * @return $this
70
	 */
71 1
	public function setUrl($url) {
72 1
		$this->url = $url;
73 1
		return $this;
74
	}
75
76
	/**
77
	 *
78
	 * @return string
79
	 */
80 1
	public function getEmail() {
81 1
		return $this->email;
82
	}
83
84
	/**
85
	 *
86
	 * @param string $email
87
	 * @return $this
88
	 */
89 1
	public function setEmail($email) {
90 1
		$this->email = $email;
91 1
		return $this;
92
	}
93
94
}
95