ZipChangesEntry.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace PhpZip\Model\Entry;
  3. use PhpZip\Exception\ZipException;
  4. /**
  5. * Source Entry Changes
  6. *
  7. * @author Ne-Lexa alexey@nelexa.ru
  8. * @license MIT
  9. */
  10. class ZipChangesEntry extends ZipAbstractEntry
  11. {
  12. /**
  13. * @var ZipSourceEntry
  14. */
  15. protected $entry;
  16. /**
  17. * ZipChangesEntry constructor.
  18. * @param ZipSourceEntry $entry
  19. */
  20. public function __construct(ZipSourceEntry $entry)
  21. {
  22. parent::__construct();
  23. $this->entry = $entry;
  24. $this->setEntry($entry);
  25. }
  26. /**
  27. * @return bool
  28. */
  29. public function isChangedContent()
  30. {
  31. return !(
  32. $this->getCompressionLevel() === $this->entry->getCompressionLevel() &&
  33. $this->getMethod() === $this->entry->getMethod() &&
  34. $this->isEncrypted() === $this->entry->isEncrypted() &&
  35. $this->getEncryptionMethod() === $this->entry->getEncryptionMethod() &&
  36. $this->getPassword() === $this->entry->getPassword()
  37. );
  38. }
  39. /**
  40. * Returns an string content of the given entry.
  41. *
  42. * @return null|string
  43. * @throws ZipException
  44. */
  45. public function getEntryContent()
  46. {
  47. return $this->entry->getEntryContent();
  48. }
  49. /**
  50. * @return ZipSourceEntry
  51. */
  52. public function getSourceEntry()
  53. {
  54. return $this->entry;
  55. }
  56. }