| Total Complexity | 8 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 76.47% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | final class LazyStream implements StreamInterface |
||
| 19 | { |
||
| 20 | use StreamDecoratorTrait; |
||
| 21 | |||
| 22 | /** @var string File to open */ |
||
| 23 | private $filename; |
||
| 24 | |||
| 25 | /** @var string $mode */ |
||
| 26 | private $mode; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $filename File to lazily open |
||
| 30 | * @param string $mode fopen mode to use when opening the stream |
||
| 31 | */ |
||
| 32 | 4 | public function __construct(string $filename, string $mode) |
|
| 33 | { |
||
| 34 | 4 | $this->filename = $filename; |
|
| 35 | 4 | $this->mode = $mode; |
|
| 36 | 4 | } |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @param string $from |
||
| 40 | * @param string $to |
||
| 41 | */ |
||
| 42 | 2 | public function replaceFilename(string $from, string $to): void |
|
| 45 | 2 | } |
|
| 46 | |||
| 47 | /** |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | 3 | public function getFilename(): string |
|
| 51 | { |
||
| 52 | 3 | return $this->filename; |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param string $filename |
||
| 57 | */ |
||
| 58 | public function setFilename(string $filename): void |
||
| 59 | { |
||
| 60 | $this->filename = $filename; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Creates the underlying stream lazily when required. |
||
| 65 | * |
||
| 66 | * @return StreamInterface |
||
| 67 | */ |
||
| 68 | 4 | protected function createStream() |
|
| 77 | } |
||
| 78 | } |
||
| 79 |