| Total Complexity | 4 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class StreamWrapper |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * The name of the stream wrapper. |
||
| 16 | * |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | public const NAME = 'cerbero-lazy-json'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * The stream context. |
||
| 23 | * |
||
| 24 | * @var resource |
||
| 25 | */ |
||
| 26 | public $context; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * The PSR-7 stream. |
||
| 30 | * |
||
| 31 | * @var StreamInterface |
||
| 32 | */ |
||
| 33 | protected $stream; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Open the stream |
||
| 37 | * |
||
| 38 | * @param string $path |
||
| 39 | * @param string $mode |
||
| 40 | * @param int $options |
||
| 41 | * @param mixed $opened_path |
||
| 42 | * @return bool |
||
| 43 | * |
||
| 44 | * @scrutinizer ignore-unused |
||
| 45 | */ |
||
| 46 | 10 | public function stream_open(string $path, string $mode, int $options, &$opened_path): bool |
|
| 47 | { |
||
| 48 | 10 | $options = stream_context_get_options($this->context); |
|
| 49 | |||
| 50 | 10 | $this->stream = $options[static::NAME]['stream'] ?? null; |
|
| 51 | |||
| 52 | 10 | return $this->stream instanceof StreamInterface && $this->stream->isReadable(); |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Determine whether the pointer is at the end of the stream |
||
| 57 | * |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | 7 | public function stream_eof(): bool |
|
| 61 | { |
||
| 62 | 7 | return $this->stream->eof(); |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Read from the stream |
||
| 67 | * |
||
| 68 | * @param int $count |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | 6 | public function stream_read(int $count): string |
|
| 74 | } |
||
| 75 | } |
||
| 76 |