PaymentResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 49
rs 10
c 3
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A __toString() 0 7 2
1
<?php
2
3
4
namespace Appino\Blockchain\Objects;
5
6
7
class PaymentResponse{
8
    /**
9
     * @var array of string
10
     */
11
    public $to;
12
    /**
13
     * @var array of string
14
     */
15
    public $from;
16
    /**
17
     * @var array of integer in satoshi
18
     */
19
    public $amount;
20
    /**
21
     * @var integer in satoshi
22
     */
23
    public $fee;
24
    /**
25
     * @var string
26
     */
27
    public $txid;
28
    /**
29
     * @var bool
30
     */
31
    public $success;
32
33
    /**
34
     * PaymentResponse constructor.
35
     * @param $params array
36
     */
37
38
    public function __construct($params){
39
        if(is_null($params))
40
            return;
41
        $this->to = data_get($params,'to');
42
        $this->from = data_get($params,'from');
43
        $this->amount = data_get($params,'amount');
44
        $this->fee = data_get($params,'fee');
45
        $this->txid = data_get($params,'txid');
46
        $this->success = data_get($params,'success');
47
    }
48
49
    public function __toString(){
50
        $class_vars = get_class_vars(get_class($this));
51
        $response = [];
52
        foreach ($class_vars as $key => $value){
53
            $response[$key] = $this->{$key};
54
        }
55
        return json_encode($response, JSON_THROW_ON_ERROR) ."";
56
    }
57
58
}
59