| Total Complexity | 8 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 11 | class ZipFileData implements ZipData |
||
| 12 | { |
||
| 13 | /** @var \SplFileInfo */ |
||
| 14 | private $file; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * ZipStringData constructor. |
||
| 18 | * |
||
| 19 | * @param \SplFileInfo $fileInfo |
||
| 20 | * |
||
| 21 | * @throws ZipException |
||
| 22 | */ |
||
| 23 | public function __construct(\SplFileInfo $fileInfo) |
||
| 24 | { |
||
| 25 | if (!$fileInfo->isFile()) { |
||
| 26 | throw new ZipException('$fileInfo is not a file.'); |
||
| 27 | } |
||
| 28 | |||
| 29 | if (!$fileInfo->isReadable()) { |
||
| 30 | throw new ZipException('$fileInfo is not readable.'); |
||
| 31 | } |
||
| 32 | |||
| 33 | $this->file = $fileInfo; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @throws ZipException |
||
| 38 | * |
||
| 39 | * @return resource returns stream data |
||
| 40 | */ |
||
| 41 | public function getDataAsStream() |
||
| 42 | { |
||
| 43 | if (!$this->file->isReadable()) { |
||
| 44 | throw new ZipException(sprintf('The %s file is no longer readable.', $this->file->getPathname())); |
||
| 45 | } |
||
| 46 | |||
| 47 | return fopen($this->file->getPathname(), 'rb'); |
||
|
|
|||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @throws ZipException |
||
| 52 | * |
||
| 53 | * @return string returns data as string |
||
| 54 | */ |
||
| 55 | public function getDataAsString() |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param resource $outStream |
||
| 66 | * |
||
| 67 | * @throws ZipException |
||
| 68 | */ |
||
| 69 | public function copyDataToStream($outStream) |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 |
If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.