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

RequiredPart   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 37.5%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 28
ccs 3
cts 8
cp 0.375
rs 10
1
<?php
2
namespace gossi\swagger\parts;
3
4
use gossi\swagger\util\MergeHelper;
5
use phootwork\collection\Map;
6
7
trait RequiredPart {
8
9
	/** @var bool */
10
	private $required;
11 5
12 5
	private function parseRequired(Map $data) {
13 5
		$this->required = $data->get('required');
14
	}
15
16
	private function mergeRequired(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...
17
		MergeHelper::mergeFields($this->required, $model->required, $overwrite);
18
	}
19
20
	/**
21
	 *
22
	 * @return bool
23
	 */
24
	public function getRequired() {
25
		return null !== $this->required ? $this->required : false;
26
	}
27
28
	/**
29
	 *
30
	 * @param bool|null $required
31
	 * @return $this
32
	 */
33
	public function setRequired($required) {
34
		$this->required = $required;
35
		return $this;
36
	}
37
38
}
39