AbstractNodeToArrayHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setMainHandler() 0 4 1
A getMainHandler() 0 8 2
getArray() 0 1 ?
isResponsible() 0 1 ?
1
<?php
2
3
namespace Saxulum\JsonDocument\NodeToArray;
4
5
use Saxulum\JsonDocument\AbstractNode;
6
7
abstract class AbstractNodeToArrayHandler
8
{
9
    /**
10
     * @var NodeToArray
11
     */
12
    protected $mainHandler;
13
14
    /**
15
     * @param  NodeToArray $mainHandler
16
     * @return void
17
     */
18
    public function setMainHandler(NodeToArray $mainHandler)
19
    {
20
        $this->mainHandler = $mainHandler;
21
    }
22
23
    /**
24
     * @return NodeToArray
25
     * @throws \Exception
26
     */
27
    public function getMainHandler()
28
    {
29
        if (null === $this->mainHandler) {
30
            throw new \Exception("This handler can't work without the main handler!");
31
        }
32
33
        return $this->mainHandler;
34
    }
35
36
    /**
37
     * @param  AbstractNode $node
38
     * @param  bool         $embedded
39
     * @return array
40
     */
41
    abstract public function getArray(AbstractNode $node, $embedded = false);
42
43
    /**
44
     * @param  AbstractNode $node
45
     * @return bool
46
     */
47
    abstract public function isResponsible(AbstractNode $node);
48
}
49