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

WalletAddress::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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