Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
StreamMetaData | |
100.00% |
14 / 14 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
createFromStream | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\IO; |
6 | |
7 | use PeServer\Core\Collection\Arr; |
8 | |
9 | /** |
10 | * `stream_get_meta_data` |
11 | */ |
12 | readonly class StreamMetaData |
13 | { |
14 | /** |
15 | * 生成。 |
16 | * |
17 | * @param bool $isTimedOut |
18 | * @param bool $isBlocked |
19 | * @param bool $eof |
20 | * @param string $streamType |
21 | * @param string $wrapperType |
22 | * @param string $mode |
23 | * @param bool $seekable |
24 | * @param string $uri |
25 | * @param array<mixed> $crypto |
26 | * @param mixed $data |
27 | * @param int $unreadBytes |
28 | */ |
29 | public function __construct( |
30 | public bool $isTimedOut, |
31 | public bool $isBlocked, |
32 | public bool $eof, |
33 | public string $streamType, |
34 | public string $wrapperType, |
35 | public string $mode, |
36 | public bool $seekable, |
37 | public string $uri, |
38 | public array $crypto, |
39 | public mixed $data, |
40 | public int $unreadBytes |
41 | ) { |
42 | } |
43 | |
44 | #region function |
45 | |
46 | /** |
47 | * `stream_get_meta_data` から作成。 |
48 | * |
49 | * @param array<string,mixed> $values |
50 | */ |
51 | public static function createFromStream(array $values): self |
52 | { |
53 | return new self( |
54 | $values['timed_out'] ?? false, |
55 | $values['blocked'] ?? false, |
56 | $values['eof'] ?? false, |
57 | (string)$values['stream_type'], |
58 | (string)$values['wrapper_type'], |
59 | (string)$values['mode'], |
60 | (bool)$values['seekable'], |
61 | (string)$values['uri'], |
62 | $values['crypto'] ?? [], |
63 | $values['wrapper_data'] ?? null, |
64 | (int)$values['unread_bytes'] |
65 | ); |
66 | } |
67 | |
68 | #endregion |
69 | } |