Passed
Push — master ( 54c1b4...a67e0e )
by Vladislav
11:20 queued 09:15
created

ExceptionResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 16
c 1
b 0
f 0
dl 0
loc 40
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getExtendedInfo() 0 3 1
A getReturnMessage() 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\DateTimeHelper;
6
use Carpenstar\ByBitAPI\Core\Interfaces\IExceptionCurlResponseInterface;
7
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseInterface;
8
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
9
10
class ExceptionResponse implements IExceptionCurlResponseInterface, IResponseInterface
11
{
12
    private int $retCode;
13
    private string $retMsg;
14
    private array $retExtInfo;
15
    private EntityCollection $result;
16
    private \DateTime $time;
17
18
    public function __construct(int $retCode, string $retMsg, ?array $retExtInfo, int $time)
19
    {
20
        $this->retCode = $retCode;
21
        $this->retMsg = $retMsg;
22
        $this->retExtInfo = $retExtInfo ?? [];
23
        $this->time = DateTimeHelper::makeFromTimestamp($time);
24
        $this->result = new EntityCollection();
25
    }
26
27
    public function getReturnCode(): int
28
    {
29
        return $this->retCode;
30
    }
31
32
    public function getReturnMessage(): string
33
    {
34
        return $this->retMsg;
35
    }
36
37
    public function getExtendedInfo(): array
38
    {
39
        return $this->retExtInfo;
40
    }
41
42
    public function getResult(): AbstractResponse
43
    {
44
        return $this->result->fetch();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->result->fetch() returns the type null which is incompatible with the type-hinted return Carpenstar\ByBitAPI\Core\Objects\AbstractResponse.
Loading history...
45
    }
46
47
    public function getTime()
48
    {
49
        return $this->time;
50
    }
51
}