BlockCallback::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
4
namespace Appino\Blockchain\Objects;
5
6
7
class BlockCallback{
8
9
    public $hash;
10
    public $confirmations;
11
    public $height;
12
    public $timestamp;
13
    public $size;
14
15
    public function __construct($params){
16
        if(is_null($params))
17
            return;
18
        foreach ($params as $key => $value){
19
            $this->{$key} = $value;
20
        }
21
    }
22
23
    public function __toString(){
24
        $class_vars = get_class_vars(get_class($this));
25
        $response = [];
26
        foreach ($class_vars as $key => $value){
27
            $response[$key] = $this->{$key};
28
        }
29
        return json_encode($response, JSON_THROW_ON_ERROR) ."";
30
    }
31
32
33
}
34