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.
   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace OpenSpout\Common;
   6  
   7  use OpenSpout\Common\Exception\InvalidArgumentException;
   8  
   9  /**
  10   * @internal
  11   */
  12  trait TempFolderOptionTrait
  13  {
  14      private string $tempFolder;
  15  
  16      final public function setTempFolder(string $tempFolder): void
  17      {
  18          if (!is_dir($tempFolder) || !is_writable($tempFolder)) {
  19              throw new InvalidArgumentException("{$tempFolder} is not a writable folder");
  20          }
  21  
  22          $this->tempFolder = $tempFolder;
  23      }
  24  
  25      final public function getTempFolder(): string
  26      {
  27          if (!isset($this->tempFolder)) {
  28              $this->setTempFolder(sys_get_temp_dir());
  29          }
  30  
  31          return $this->tempFolder;
  32      }
  33  }