Passed
Branch master (0e771b)
by Vladislav
07:54
created

ExceptionResponse   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 14
c 2
b 0
f 0
dl 0
loc 42
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getExtendedInfo() 0 3 1
A getReturnMessage() 0 3 1
A isSuccess() 0 3 1
A getReturnCode() 0 3 1
A getTime() 0 3 1
A getResult() 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\Interfaces\IResponseInterface;
9
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
10
11
class ExceptionResponse implements IResponseDataInterface, IResponseInterface
12
{
13
    private bool $isSuccess;
14
    private string $retMsg;
15
    private \DateTime $time;
16
17
    public function __construct(array $data)
18
    {
19
        $this->isSuccess = BoolHelper::assign($data['success']);
20
        $this->retMsg = StringHelper::assign($data['ret_msg']);
21
        $this->time = (new \DateTime());
22
        $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...
23
    }
24
25
    public function isSuccess(): bool
26
    {
27
        return $this->isSuccess;
28
    }
29
30
    public function getReturnMessage(): string
31
    {
32
        return $this->retMsg;
33
    }
34
35
    public function getTime(): \DateTime
36
    {
37
        return $this->time;
38
    }
39
40
    public function getReturnCode(): int
41
    {
42
        return -1;
43
    }
44
45
    public function getExtendedInfo(): array
46
    {
47
        return [];
48
    }
49
50
    public function getResult()
51
    {
52
        return null;
53
    }
54
}
55