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

ExceptionResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 4
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
}