Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 400 and 402] [Versions 401 and 402]

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