Esempio n. 1
0
 /**
  * Sets protected properties based on config provided
  *
  * @param array $config Configuration array
  */
 public function __construct(array $config = [])
 {
     parent::__construct($config);
     if (!empty($this->_config['path'])) {
         $this->_path = $this->_config['path'];
     }
     if (Configure::read('debug') && !is_dir($this->_path)) {
         mkdir($this->_path, 0775, true);
     }
     if (!empty($this->_config['file'])) {
         $this->_file = $this->_config['file'];
         if (substr($this->_file, -4) !== '.log') {
             $this->_file .= '.log';
         }
     }
     if (!empty($this->_config['size'])) {
         if (is_numeric($this->_config['size'])) {
             $this->_size = (int) $this->_config['size'];
         } else {
             $this->_size = String::parseFileSize($this->_config['size']);
         }
     }
 }
Esempio n. 2
0
 /**
  * Checks the filesize
  *
  * @param string|array $check Value to check.
  * @param string $operator See `Validation::comparison()`.
  * @param int|string $size Size in bytes or human readable string like '5MB'.
  * @return bool Success
  */
 public static function fileSize($check, $operator = null, $size = null)
 {
     if (is_array($check) && isset($check['tmp_name'])) {
         $check = $check['tmp_name'];
     }
     if (is_string($size)) {
         $size = String::parseFileSize($size);
     }
     $filesize = filesize($check);
     return static::comparison($filesize, $operator, $size);
 }
Esempio n. 3
0
 /**
  * testparseFileSizeException
  *
  * @expectedException InvalidArgumentException
  * @return void
  */
 public function testparseFileSizeException()
 {
     String::parseFileSize('bogus', false);
 }