Passed
Push — main ( b86878...e52c85 )
by Pouya
05:24
created

AccountResponse::__toString()   A

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
use Psy\Util\Json;
0 ignored issues
show
Bug introduced by
The type Psy\Util\Json was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class AccountResponse{
9
    /**
10
     * @var string
11
     */
12
    public $balance;
13
    /**
14
     * @var string
15
     */
16
    public $label;
17
    /**
18
     * @var string
19
     */
20
    public $index;
21
    /**
22
     * @var string
23
     */
24
    public $archived;
25
    /**
26
     * @var string
27
     */
28
    public $extendedPublicKey;
29
    /**
30
     * @var string
31
     */
32
    public $extendedPrivateKey;
33
    /**
34
     * @var string
35
     */
36
    public $receiveIndex;
37
    /**
38
     * @var string
39
     */
40
    public $lastUsedReceiveIndex;
41
    /**
42
     * @var string
43
     */
44
    public $receiveAddress;
45
46
    /**
47
     * AccountResponse constructor.
48
     * @param $params array|object
49
     */
50
51
    public function __construct($params){
52
        //echo Json::encode($params);
53
        if(is_null($params))
54
            return;
55
        $this->balance = data_get($params,'balance');
56
        $this->label = data_get($params,'label');
57
        $this->index = data_get($params,'index');
58
        $this->archived = data_get($params,'archived');
59
        $this->extendedPublicKey = data_get($params,'extendedPublicKey');
60
        $this->extendedPrivateKey = data_get($params,'extendedPrivateKey');
61
        $this->receiveIndex = data_get($params,'receiveIndex');
62
        $this->lastUsedReceiveIndex = data_get($params,'lastUsedReceiveIndex');
63
        $this->receiveAddress = data_get($params,'receiveAddress');
64
    }
65
66
    public function __toString(){
67
        $class_vars = get_class_vars(get_class($this));
68
        $response = [];
69
        foreach ($class_vars as $key => $value){
70
            $response[$key] = $this->{$key};
71
        }
72
        return Json::encode($response);
73
    }
74
75
}
76