Test Failed
Pull Request — master (#4)
by Vladislav
14:06 queued 06:14
created

OpenInterestResponse::setTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Dto;
3
4
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
5
use Carpenstar\ByBitAPI\Core\Objects\ResponseEntity;
6
7
class OpenInterestResponse extends ResponseEntity
8
{
9
    /**
10
     * Open interest
11
     * @var string $openInterest
12
     */
13
    private string $openInterest;
14
15
    /**
16
     * The timestamp
17
     * @var \DateTime $timestamp
18
     */
19
    private \DateTime $timestamp;
20
21
    public function __construct(array $data)
22
    {
23
        $this
24
            ->setOpenInterest($data['openInterest'])
25
            ->setTimestamp($data['timestamp']);
26
    }
27
28
    /**
29
     * @param string $openInterest
30
     * @return OpenInterestResponse
31
     */
32
    public function setOpenInterest(string $openInterest): self
33
    {
34
        $this->openInterest = $openInterest;
35
        return $this;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getOpenInterest(): string
42
    {
43
        return $this->openInterest;
44
    }
45
46
    /**
47
     * @param int $timestamp
48
     * @return OpenInterestResponse
49
     */
50
    private function setTimestamp(int $timestamp): self
51
    {
52
        $this->timestamp = DateTimeHelper::makeFromTimestamp($timestamp);
53
        return $this;
54
    }
55
56
    /**
57
     * @return \DateTime
58
     */
59
    public function getTimestamp(): \DateTime
60
    {
61
        return $this->timestamp;
62
    }
63
64
65
}