Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

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