Passed
Pull Request — master (#31)
by Vladislav
07:58
created

ExceptionResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 17
c 1
b 0
f 0
dl 0
loc 34
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getReturnMessage() 0 3 1
A isSuccess() 0 3 1
A getTime() 0 3 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Core\Objects;
4
5
use Carpenstar\ByBitAPI\Core\Helpers\BoolHelper;
6
use Carpenstar\ByBitAPI\Core\Helpers\StringHelper;
7
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseDataInterface;
8
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
9
10
class ExceptionResponse implements IResponseDataInterface
11
{
12
    private bool $isSuccess;
13
    private string $retMsg;
14
    private string $connectionId;
15
    private \DateTime $time;
16
    private string $reqId;
17
    private string $operation;
18
19
    public function __construct(array $data)
20
    {
21
        $this->isSuccess = BoolHelper::assign($data['success']);
22
        $this->retMsg = StringHelper::assign($data['ret_msg']);
23
        $this->connectionId = StringHelper::assign($data['conn_id']);
24
        $this->reqId = StringHelper::assign($data['req_id']);
25
        $this->operation = StringHelper::assign($data['op']);
26
27
        $this->time = (new \DateTime());
28
        $this->result = new EntityCollection();
0 ignored issues
show
Bug Best Practice introduced by
The property result does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
    }
30
31
    public function isSuccess(): bool
32
    {
33
        return $this->isSuccess;
34
    }
35
36
    public function getReturnMessage(): string
37
    {
38
        return $this->retMsg;
39
    }
40
41
    public function getTime()
42
    {
43
        return $this->time;
44
    }
45
}
46