Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

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