| Total Complexity | 7 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class Headers extends NetworkSerializable implements \Countable |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var BufferInterface[] |
||
| 16 | */ |
||
| 17 | private $headers = []; |
||
| 18 | |||
| 19 | public function __construct(BufferInterface ...$headers) |
||
| 20 | { |
||
| 21 | 12 | $this->headers = $headers; |
|
| 22 | } |
||
| 23 | 12 | ||
| 24 | 9 | /** |
|
| 25 | 8 | * @return string |
|
| 26 | 12 | * @see https://en.bitcoin.it/wiki/Protocol_documentation#headers |
|
| 27 | */ |
||
| 28 | public function getNetworkCommand(): string |
||
| 29 | { |
||
| 30 | return Message::HEADERS; |
||
| 31 | } |
||
| 32 | 9 | ||
| 33 | /** |
||
| 34 | 9 | * @return BufferInterface[] |
|
| 35 | 9 | */ |
|
| 36 | public function getHeaders(): array |
||
| 39 | } |
||
| 40 | 6 | ||
| 41 | /** |
||
| 42 | 6 | * @return int |
|
| 43 | */ |
||
| 44 | public function count(): int |
||
| 45 | { |
||
| 46 | return count($this->headers); |
||
| 47 | } |
||
| 48 | 9 | ||
| 49 | /** |
||
| 50 | 9 | * @param int $index |
|
| 51 | * @return BufferInterface |
||
| 52 | */ |
||
| 53 | public function getHeader(int $index): BufferInterface |
||
| 54 | { |
||
| 55 | if (!array_key_exists($index, $this->headers)) { |
||
| 56 | 6 | throw new \InvalidArgumentException('No header exists at this index'); |
|
| 57 | } |
||
| 58 | 6 | ||
| 59 | return $this->headers[$index]; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritdoc} |
||
| 64 | * @see \BitWasp\Bitcoin\SerializableInterface::getBuffer() |
||
| 65 | 6 | */ |
|
| 66 | public function getBuffer(): BufferInterface |
||
| 69 | } |
||
| 70 | } |
||
| 71 |