File.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. declare(strict_types=1);
  3. namespace ZipStream\Option;
  4. use DateTime;
  5. final class File
  6. {
  7. /**
  8. * @var string
  9. */
  10. private $comment = '';
  11. /**
  12. * @var Method
  13. */
  14. private $method;
  15. /**
  16. * @var int
  17. */
  18. private $deflateLevel;
  19. /**
  20. * @var DateTime
  21. */
  22. private $time;
  23. /**
  24. * @var int
  25. */
  26. private $size = 0;
  27. public function defaultTo(Archive $archiveOptions): void
  28. {
  29. $this->deflateLevel = $this->deflateLevel ?: $archiveOptions->getDeflateLevel();
  30. $this->time = $this->time ?: new DateTime();
  31. }
  32. /**
  33. * @return string
  34. */
  35. public function getComment(): string
  36. {
  37. return $this->comment;
  38. }
  39. /**
  40. * @param string $comment
  41. */
  42. public function setComment(string $comment): void
  43. {
  44. $this->comment = $comment;
  45. }
  46. /**
  47. * @return Method
  48. */
  49. public function getMethod(): Method
  50. {
  51. return $this->method ?: Method::DEFLATE();
  52. }
  53. /**
  54. * @param Method $method
  55. */
  56. public function setMethod(Method $method): void
  57. {
  58. $this->method = $method;
  59. }
  60. /**
  61. * @return int
  62. */
  63. public function getDeflateLevel(): int
  64. {
  65. return $this->deflateLevel ?: Archive::DEFAULT_DEFLATE_LEVEL;
  66. }
  67. /**
  68. * @param int $deflateLevel
  69. */
  70. public function setDeflateLevel(int $deflateLevel): void
  71. {
  72. $this->deflateLevel = $deflateLevel;
  73. }
  74. /**
  75. * @return DateTime
  76. */
  77. public function getTime(): DateTime
  78. {
  79. return $this->time;
  80. }
  81. /**
  82. * @param DateTime $time
  83. */
  84. public function setTime(DateTime $time): void
  85. {
  86. $this->time = $time;
  87. }
  88. /**
  89. * @return int
  90. */
  91. public function getSize(): int
  92. {
  93. return $this->size;
  94. }
  95. /**
  96. * @param int $size
  97. */
  98. public function setSize(int $size): void
  99. {
  100. $this->size = $size;
  101. }
  102. }