AccountResponse::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 9.9
1
<?php
2
3
namespace Appino\Blockchain\Objects;
4
5
6
class AccountResponse{
7
    /**
8
     * @var string
9
     */
10
    public $balance;
11
    /**
12
     * @var string
13
     */
14
    public $label;
15
    /**
16
     * @var string
17
     */
18
    public $index;
19
    /**
20
     * @var string
21
     */
22
    public $archived;
23
    /**
24
     * @var string
25
     */
26
    public $extendedPublicKey;
27
    /**
28
     * @var string
29
     */
30
    public $extendedPrivateKey;
31
    /**
32
     * @var string
33
     */
34
    public $receiveIndex;
35
    /**
36
     * @var string
37
     */
38
    public $lastUsedReceiveIndex;
39
    /**
40
     * @var string
41
     */
42
    public $receiveAddress;
43
44
    /**
45
     * AccountResponse constructor.
46
     * @param $params array|object
47
     */
48
49
    public function __construct($params){
50
        if(is_null($params))
51
            return;
52
        $this->balance = data_get($params,'balance');
53
        $this->label = data_get($params,'label');
54
        $this->index = data_get($params,'index');
55
        $this->archived = data_get($params,'archived');
56
        $this->extendedPublicKey = data_get($params,'extendedPublicKey');
57
        $this->extendedPrivateKey = data_get($params,'extendedPrivateKey');
58
        $this->receiveIndex = data_get($params,'receiveIndex');
59
        $this->lastUsedReceiveIndex = data_get($params,'lastUsedReceiveIndex');
60
        $this->receiveAddress = data_get($params,'receiveAddress');
61
    }
62
63
    public function __toString(){
64
        $class_vars = get_class_vars(get_class($this));
65
        $response = [];
66
        foreach ($class_vars as $key => $value){
67
            $response[$key] = $this->{$key};
68
        }
69
        return json_encode($response, JSON_THROW_ON_ERROR) ."";
70
    }
71
72
}
73