ZipOutputZipFileEntry.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace PhpZip\Output;
  3. use PhpZip\Exception\ZipException;
  4. use PhpZip\Model\ZipEntry;
  5. use PhpZip\ZipFile;
  6. /**
  7. * Zip output entry for input zip file.
  8. *
  9. * @author Ne-Lexa alexey@nelexa.ru
  10. * @license MIT
  11. */
  12. class ZipOutputZipFileEntry extends ZipOutputEntry
  13. {
  14. /**
  15. * Input zip file.
  16. *
  17. * @var ZipFile
  18. */
  19. private $inputZipFile;
  20. /**
  21. * Input entry name.
  22. *
  23. * @var string
  24. */
  25. private $inputEntryName;
  26. /**
  27. * ZipOutputZipFileEntry constructor.
  28. * @param ZipFile $zipFile
  29. * @param ZipEntry $zipEntry
  30. * @throws ZipException If input zip file is null.
  31. */
  32. public function __construct(ZipFile $zipFile, ZipEntry $zipEntry)
  33. {
  34. if ($zipFile === null) {
  35. throw new ZipException('ZipFile is null');
  36. }
  37. parent::__construct(clone $zipEntry);
  38. $this->inputZipFile = $zipFile;
  39. $this->inputEntryName = $zipEntry->getName();
  40. }
  41. /**
  42. * Returns entry data.
  43. *
  44. * @return string
  45. */
  46. public function getEntryContent()
  47. {
  48. return $this->inputZipFile->getEntryContent($this->inputEntryName);
  49. }
  50. }