ZipChangesEntry.php 1.5 KB

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