MissingNodeSerializer::serialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.6666
nc 2
cc 2
eloc 5
nop 1
crap 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