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

PaymentResponse::__toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Appino\Blockchain\Objects;
5
6
7
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...
8
9
class PaymentResponse{
10
    /**
11
     * @var array of string
12
     */
13
    public $to;
14
    /**
15
     * @var array of string
16
     */
17
    public $from;
18
    /**
19
     * @var array of integer in satoshi
20
     */
21
    public $amount;
22
    /**
23
     * @var integer in satoshi
24
     */
25
    public $fee;
26
    /**
27
     * @var string
28
     */
29
    public $txid;
30
    /**
31
     * @var bool
32
     */
33
    public $success;
34
35
    /**
36
     * PaymentResponse constructor.
37
     * @param $params array
38
     */
39
40
    public function __construct($params){
41
        if(is_null($params))
42
            return;
43
        $this->to = data_get($params,'to');
44
        $this->from = data_get($params,'from');
45
        $this->amount = data_get($params,'amount');
46
        $this->fee = data_get($params,'fee');
47
        $this->txid = data_get($params,'txid');
48
        $this->success = data_get($params,'success');
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