Completed
Push — master ( a7ae23...b30b3b )
by Thomas
09:53
created

SubdivisionSerializerTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 54
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributes() 0 12 1
A getFields() 0 3 1
A getId() 0 3 1
A getSortFields() 0 3 1
A getType() 0 3 1
A hydrate() 0 4 1
1
<?php
2
namespace keeko\core\serializer\base;
3
4
/**
5
 */
6
trait SubdivisionSerializerTrait {
7
8
	/**
9
	 * @param mixed $model
10
	 * @param array $fields
11
	 */
12
	public function getAttributes($model, array $fields = null) {
1 ignored issue
show
Unused Code introduced by
The parameter $fields is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
		return [
14
			'id' => $model->Id(),
15
			'code' => $model->Code(),
16
			'name' => $model->Name(),
17
			'native_name' => $model->NativeName(),
18
			'alt_names' => $model->AltNames(),
19
			'parent_id' => $model->ParentId(),
20
			'country_id' => $model->CountryId(),
21
			'type_id' => $model->TypeId(),
22
		];
23
	}
24
25
	/**
26
	 */
27
	public function getFields() {
28
		return ['id', 'code', 'name', 'native_name', 'alt_names', 'parent_id', 'country_id', 'type_id'];
29
	}
30
31
	/**
32
	 * @param mixed $model
33
	 */
34
	public function getId($model) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
35
		return $model->getId();
36
	}
37
38
	/**
39
	 */
40
	public function getSortFields() {
41
		return ['id', 'code', 'name', 'native_name', 'alt_names', 'parent_id', 'country_id', 'type_id'];
42
	}
43
44
	/**
45
	 * @param mixed $model
46
	 */
47
	public function getType($model) {
1 ignored issue
show
Unused Code introduced by
The parameter $model is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
		return 'core/subdivision';
49
	}
50
51
	/**
52
	 * @param mixed $model
53
	 * @param mixed $data
54
	 */
55
	public function hydrate($model, $data) {
1 ignored issue
show
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
		// this model is read-only!
57
		return $model;
58
	}
59
}
60