MissingNodeSerializer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 22
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isSerializerFor() 0 3 2
A serialize() 0 9 2
1
<?php
2
3
namespace PPP\DataModel\Serializers;
4
5
use PPP\DataModel\MissingNode;
6
use Serializers\DispatchableSerializer;
7
use Serializers\Exceptions\UnsupportedObjectException;
8
9
/**
10
 * @licence AGPLv3+
11
 * @author Thomas Pellissier Tanon
12
 */
13
class MissingNodeSerializer implements DispatchableSerializer {
14
15
	/**
16
	 * @see DispatchableSerializer::isSerializerFor
17
	 */
18 8
	public function isSerializerFor($object) {
19 8
		return is_object($object) && $object instanceof MissingNode;
20
	}
21
22
	/**
23
	 * @see Serializer::serialize
24
	 */
25 4
	public function serialize($object) {
26 4
		if(!$this->isSerializerFor($object)) {
27 3
			throw new UnsupportedObjectException($object, 'MissingNodeSerializer can only serialize MissingNode objects.');
28
		}
29
30
		return array(
31
			'type' => 'missing'
32 1
		);
33
	}
34
}
35