Response::json_handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
namespace UAPAY\Orders\Show;
4
5
use UAPAY\Log as Log;
6
use UAPAY\Exception;
7
8
class Response extends \UAPAY\Response
9
{
10
    /**
11
     *      @var string
12
     */
13
    protected $id;
14
15
    /**
16
     *      @var array
17
     */
18
    protected $data;
19
20
    /**
21
     *      Handle decoded JSON
22
     *
23
     *      @throws Exception\JSON
24
     */
25
    protected function json_handle()
26
    {
27
        parent::json_handle();
28
29
        if (!isset($this->json['data']['id']))
30
        {
31
            throw new Exception\JSON('data does not contain the id field!');
32
        }
33
34
        $this->id = $this->json['data']['id'];
35
36
        $this->data = $this->json['data'];
37
    }
38
39
    /**
40
     *      Get session id
41
     *
42
     *      @return string id session
43
     */
44
    public function id()
45
    {
46
        return $this->id;
47
    }
48
49
    /**
50
     *      Get info about order
51
     *
52
     *      @return array data
53
     */
54
    public function data()
55
    {
56
        return $this->data;
57
    }
58
}
59