UnknownResourceNodeSerializer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 25
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isSerializerFor() 0 3 2
A serialize() 0 7 2
1
<?php
2
3
namespace PPP\DataModel\Serializers;
4
5
use PPP\DataModel\UnknownResourceNode;
6
use Serializers\Exceptions\UnsupportedObjectException;
7
8
/**
9
 * @licence MIT
10
 * @author Thomas Pellissier Tanon
11
 */
12
class UnknownResourceNodeSerializer extends BasicResourceNodeSerializer {
13
14 9
	public function __construct() {
15 9
		parent::__construct('resource', 'type');
0 ignored issues
show
Unused Code introduced by
The call to BasicResourceNodeSerializer::__construct() has too many arguments starting with 'type'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
16 9
	}
17
18
	/**
19
	 * @see DispatchableSerializer::isSerializerFor
20
	 */
21 8
	public function isSerializerFor($object) {
22 8
		return is_object($object) && $object instanceof UnknownResourceNode;
23
	}
24
25
	/**
26
	 * @see Serializer::serialize
27
	 * @param UnknownResourceNode $object
28
	 */
29 4
	public function serialize($object) {
30 4
		if(!$this->isSerializerFor($object)) {
31 3
			throw new UnsupportedObjectException($object, 'UnkownResourceNodeSerializer can only serialize UnknownResourceNode objects.');
32
		}
33
34 1
		return $object->getProperties();
35
	}
36
}
37