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

OpenInterestResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setTimestamp() 0 4 1
A __construct() 0 5 1
A setOpenInterest() 0 4 1
A getTimestamp() 0 3 1
A getOpenInterest() 0 3 1
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
}