2
0

JarMarkerExtraField.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace PhpZip\Extra\Fields;
  3. use PhpZip\Exception\ZipException;
  4. use PhpZip\Extra\ExtraField;
  5. /**
  6. * Jar Marker Extra Field
  7. * An executable Java program can be packaged in a JAR file with all the libraries it uses.
  8. * Executable JAR files can easily be distinguished from the files packed in the JAR file
  9. * by the extra field in the first file, which is hexadecimal in the 0xCAFE bytes series.
  10. *
  11. * @author Ne-Lexa alexey@nelexa.ru
  12. * @license MIT
  13. */
  14. class JarMarkerExtraField implements ExtraField
  15. {
  16. /**
  17. * Returns the Header ID (type) of this Extra Field.
  18. * The Header ID is an unsigned short integer (two bytes)
  19. * which must be constant during the life cycle of this object.
  20. *
  21. * @return int
  22. */
  23. public static function getHeaderId()
  24. {
  25. return 0xCAFE;
  26. }
  27. /**
  28. * Serializes a Data Block.
  29. *
  30. * @return string
  31. */
  32. public function serialize()
  33. {
  34. return '';
  35. }
  36. /**
  37. * Initializes this Extra Field by deserializing a Data Block.
  38. *
  39. * @param string $data
  40. *
  41. * @throws ZipException
  42. */
  43. public function deserialize($data)
  44. {
  45. if ($data !== '') {
  46. throw new ZipException("JarMarker doesn't expect any data");
  47. }
  48. }
  49. }