ZipExtraField.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace PhpZip\Model\Extra;
  3. use PhpZip\Model\ZipEntry;
  4. /**
  5. * Extra Field in a Local or Central Header of a ZIP archive.
  6. * It defines the common properties of all Extra Fields and how to
  7. * serialize/unserialize them to/from byte arrays.
  8. */
  9. interface ZipExtraField
  10. {
  11. /**
  12. * Returns the Header ID (type) of this Extra Field.
  13. * The Header ID is an unsigned short integer (two bytes)
  14. * which must be constant during the life cycle of this object.
  15. *
  16. * @return int
  17. */
  18. public function getHeaderId();
  19. /**
  20. * Populate data from this array as if it was in local file data.
  21. *
  22. * @param string $buffer the buffer to read data from
  23. * @param ZipEntry|null $entry
  24. *
  25. * @return static
  26. */
  27. public static function unpackLocalFileData($buffer, ZipEntry $entry = null);
  28. /**
  29. * Populate data from this array as if it was in central directory data.
  30. *
  31. * @param string $buffer the buffer to read data from
  32. * @param ZipEntry|null $entry
  33. *
  34. * @return static
  35. */
  36. public static function unpackCentralDirData($buffer, ZipEntry $entry = null);
  37. /**
  38. * The actual data to put into local file data - without Header-ID
  39. * or length specifier.
  40. *
  41. * @return string the data
  42. */
  43. public function packLocalFileData();
  44. /**
  45. * The actual data to put into central directory - without Header-ID or
  46. * length specifier.
  47. *
  48. * @return string the data
  49. */
  50. public function packCentralDirData();
  51. /**
  52. * @return string
  53. */
  54. public function __toString();
  55. }