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

ActivityObjectSerializerTrait   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributes() 0 12 1
A getFields() 0 3 1
A getId() 0 3 1
A getRelationships() 0 4 1
A getSortFields() 0 3 1
A getType() 0 3 1
A hydrate() 0 11 2
1
<?php
2
namespace keeko\core\serializer\base;
3
4
use keeko\framework\utils\HydrateUtils;
5
6
/**
7
 */
8
trait ActivityObjectSerializerTrait {
9
10
	/**
11
	 * @param mixed $model
12
	 * @param array $fields
13
	 */
14
	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...
15
		return [
16
			'id' => $model->Id(),
17
			'class_name' => $model->ClassName(),
18
			'type' => $model->Type(),
19
			'display_name' => $model->DisplayName(),
20
			'url' => $model->Url(),
21
			'reference_id' => $model->ReferenceId(),
22
			'version' => $model->Version(),
23
			'extra' => $model->Extra(),
24
		];
25
	}
26
27
	/**
28
	 */
29
	public function getFields() {
30
		return ['id', 'class_name', 'type', 'display_name', 'url', 'reference_id', 'version', 'extra'];
31
	}
32
33
	/**
34
	 * @param mixed $model
35
	 */
36
	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...
37
		return $model->getId();
38
	}
39
40
	/**
41
	 */
42
	public function getRelationships() {
43
		return [
44
		];
45
	}
46
47
	/**
48
	 */
49
	public function getSortFields() {
50
		return ['id', 'class_name', 'type', 'display_name', 'url', 'reference_id', 'version', 'extra'];
51
	}
52
53
	/**
54
	 * @param mixed $model
55
	 */
56
	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...
57
		return 'core/activity-object';
58
	}
59
60
	/**
61
	 * @param mixed $model
62
	 * @param mixed $data
63
	 */
64
	public function hydrate($model, $data) {
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...
65
		// attributes
66
		$attribs = isset($data['attributes']) ? $data['attributes'] : [];
67
68
		$model = HydrateUtils::hydrate($attribs, $model, ['id', 'class_name', 'type', 'display_name', 'url', 'reference_id', 'version', 'extra']);
69
70
		// relationships
71
		$this->hydrateRelationships($model, $data);
0 ignored issues
show
Bug introduced by
The method hydrateRelationships() does not exist on keeko\core\serializer\ba...tyObjectSerializerTrait. Did you maybe mean hydrate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
72
73
		return $model;
74
	}
75
}
76