Json   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A newData() 0 3 1
A fromArray() 0 3 1
1
<?php
2
3
namespace Ghc\Rosetta\Messages;
4
5
class Json extends Message
6
{
7
    /**
8
     * @return string
9
     */
10
    public function newData()
11
    {
12
        return '{}';
13
    }
14
15
    /**
16
     * Get the instance as an array.
17
     *
18
     * @return array
19
     */
20
    public function toArray()
21
    {
22
        return json_decode($this->getData(), true);
23
    }
24
25
    /**
26
     * @param array $data
27
     *
28
     * @return self
29
     */
30
    public function fromArray($data)
31
    {
32
        return $this->setData(json_encode($data));
33
    }
34
}
35