-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathErrorIterator.php
More file actions
44 lines (36 loc) · 862 Bytes
/
ErrorIterator.php
File metadata and controls
44 lines (36 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types=1);
namespace MpApiClient\Checks\Entity;
use MpApiClient\Common\Util\AbstractIntKeyIterator;
/**
* @extends AbstractIntKeyIterator<Error>
* @property Error[] $data
*/
final class ErrorIterator extends AbstractIntKeyIterator
{
private function __construct(Error ...$data)
{
$this->data = $data;
}
/**
* @param array<int, array<string, mixed>> $data
*
* @internal
*/
public static function createFromApi(array $data): self
{
return new self(
...array_map(fn(array $item): Error => Error::createFromApi($item), $data)
);
}
/**
* @return false|Error
*/
public function current()
{
return current($this->data);
}
public function get(int $key): ?Error
{
return $this->data[$key] ?? null;
}
}