WalletAddress::__toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Appino\Blockchain\Objects;
4
5
use Appino\Blockchain\Objects\Cache;
6
7
class WalletAddress{
8
    /**
9
     * @var string
10
     */
11
    public $label;
12
    /**
13
     * @var string
14
     */
15
    public $archived;
16
    /**
17
     * @var string
18
     */
19
    public $xpriv;
20
    /**
21
     * @var string
22
     */
23
    public $xpub;
24
    /**
25
     * @var array
26
     */
27
    public $addresslabels;
28
    /**
29
     * @var Cache
30
     */
31
    public $cahce;
32
33
    /**
34
     * AccountResponse constructor.
35
     * @param $params array|object
36
     */
37
38
    public function __construct($params){
39
        //echo Json::encode($params);
40
        if(is_null($params))
41
            return;
42
        $this->label = data_get($params,'label');
43
        $this->archived = data_get($params,'archived');
44
        $this->xpriv = data_get($params,'xpriv');
45
        $this->xpub = data_get($params,'xpub');
46
        $this->addresslabels = data_get($params,'addresslabels',array());
47
        $this->cahce = new Cache(data_get($params,'cache'));
48
    }
49
50
    public function __toString(){
51
        $class_vars = get_class_vars(get_class($this));
52
        $response = [];
53
        foreach ($class_vars as $key => $value){
54
            $response[$key] = $this->{$key};
55
        }
56
        return json_encode($response, JSON_THROW_ON_ERROR) ."";
57
    }
58
59
}
60