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

Json::setJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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
}