WalletResponse::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Appino\Blockchain\Objects;
4
5
class WalletResponse{
6
7
    /**
8
     * @var string
9
     */
10
    public $guid;
11
    /**
12
     * @var string
13
     */
14
    public $address;
15
    /**
16
     * @var string
17
     */
18
    public $label;
19
20
    /**
21
     * AccountResponse constructor.
22
     * @param $params array|object
23
     */
24
25
    public function __construct($params){
26
        if(is_null($params))
27
            return;
28
        $this->guid = data_get($params,'guid');
29
        $this->address = data_get($params,'address');
30
        $this->label = data_get($params,'label');
31
    }
32
33
    public function __toString(){
34
        $class_vars = get_class_vars(get_class($this));
35
        $response = [];
36
        foreach ($class_vars as $key => $value){
37
            $response[$key] = $this->{$key};
38
        }
39
        return json_encode($response, JSON_THROW_ON_ERROR) ."";
40
    }
41
42
}
43