Completed
Push — master ( d6a6e9...1d4c8e )
by Thomas
10:31
created

CountrySerializer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
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 69
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
B getAttributes() 0 27 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\model\serializer;
3
4
use keeko\framework\model\AbstractSerializer;
5
6
/**
7
 */
8
class CountrySerializer extends AbstractSerializer {
9
10
	/**
11
	 * @param mixed $model
12
	 * @param array $fields
13
	 */
14
	public function getAttributes($model, array $fields = null) {
15
		return [
16
			'id' => $model->Id(),
17
			'numeric' => $model->Numeric(),
18
			'alpha_2' => $model->Alpha2(),
19
			'alpha_3' => $model->Alpha3(),
20
			'short_name' => $model->ShortName(),
21
			'ioc' => $model->Ioc(),
22
			'tld' => $model->Tld(),
23
			'phone' => $model->Phone(),
24
			'capital' => $model->Capital(),
25
			'postal_code_format' => $model->PostalCodeFormat(),
26
			'postal_code_regex' => $model->PostalCodeRegex(),
27
			'continent_id' => $model->ContinentId(),
28
			'currency_id' => $model->CurrencyId(),
29
			'type_id' => $model->TypeId(),
30
			'subtype_id' => $model->SubtypeId(),
31
			'sovereignity_id' => $model->SovereignityId(),
32
			'formal_name' => $model->FormalName(),
33
			'formal_native_name' => $model->FormalNativeName(),
34
			'short_native_name' => $model->ShortNativeName(),
35
			'bbox_sw_lat' => $model->BboxSwLat(),
36
			'bbox_sw_lng' => $model->BboxSwLng(),
37
			'bbox_ne_lat' => $model->BboxNeLat(),
38
			'bbox_ne_lng' => $model->BboxNeLng(),
39
		];
40
	}
41
42
	/**
43
	 */
44
	public function getFields() {
45
		return ['id', 'numeric', 'alpha_2', 'alpha_3', 'short_name', 'ioc', 'tld', 'phone', 'capital', 'postal_code_format', 'postal_code_regex', 'continent_id', 'currency_id', 'type_id', 'subtype_id', 'sovereignity_id', 'formal_name', 'formal_native_name', 'short_native_name', 'bbox_sw_lat', 'bbox_sw_lng', 'bbox_ne_lat', 'bbox_ne_lng'];
46
	}
47
48
	/**
49
	 * @param mixed $model
50
	 */
51
	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...
52
		return $model->getId();
53
	}
54
55
	/**
56
	 */
57
	public function getSortFields() {
58
		return ['id', 'numeric', 'alpha_2', 'alpha_3', 'short_name', 'ioc', 'tld', 'phone', 'capital', 'postal_code_format', 'postal_code_regex', 'continent_id', 'currency_id', 'type_id', 'subtype_id', 'sovereignity_id', 'formal_name', 'formal_native_name', 'short_native_name', 'bbox_sw_lat', 'bbox_sw_lng', 'bbox_ne_lat', 'bbox_ne_lng'];
59
	}
60
61
	/**
62
	 * @param mixed $model
63
	 */
64
	public function getType($model) {
65
		return 'core/country';
66
	}
67
68
	/**
69
	 * @param mixed $model
70
	 * @param mixed $data
71
	 */
72
	public function hydrate($model, $data) {
73
		// this model is read-only!
74
		return $model;
75
	}
76
}
77