Passed
Push — master ( 6618ba...909ba3 )
by Jon
02:44
created

Json   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getComponent() 0 3 1
A __construct() 0 13 3
A setJson() 0 3 1
1
<?php
2
3
namespace FlatPlan\Components;
4
5
class Json extends AbstractComponent {
6
7
    protected $json;
8
9
    /**
10
     * @param string $json
11
     * @return bool
12
     */
13
    public function __construct($json)
14
    {
15
        if (empty($json)) {
16
            return false;
17
        }
18
19
        $object = json_decode($json);
20
        if ($object instanceof \stdClass) {
21
            $this->setJson($object);
22
            return true;
23
        }
24
25
        return false;
26
    }
27
28
    private function setJson($json)
29
    {
30
        $this->json = $json;
31
    }
32
33
    public function getComponent()
34
    {
35
        return $this->json;
36
    }
37
}