/**
  * Sets validator options
  *
  * Min limits the used disk space for all files, when used with max=null it is the maximum file size
  * It also accepts an array with the keys 'min' and 'max'
  *
  * @param  int|array|Traversable $options Options for this validator
  * @throws \Zend\Validator\Exception\InvalidArgumentException
  */
 public function __construct($options = null)
 {
     $this->files = [];
     $this->setSize(0);
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     } elseif (is_scalar($options)) {
         $options = ['max' => $options];
     } elseif (!is_array($options)) {
         throw new Exception\InvalidArgumentException('Invalid options to validator provided');
     }
     if (1 < func_num_args()) {
         $argv = func_get_args();
         array_shift($argv);
         $options['max'] = array_shift($argv);
         if (!empty($argv)) {
             $options['useByteString'] = array_shift($argv);
         }
     }
     parent::__construct($options);
 }
Esempio n. 2
0
 /**
  * Sets validator options
  *
  * Min limits the used diskspace for all files, when used with max=null it is the maximum filesize
  * It also accepts an array with the keys 'min' and 'max'
  *
  * @param  integer|array|\Zend\Config\Config $options Options for this validator
  * @return void
  */
 public function __construct($options = null)
 {
     $this->_files = array();
     $this->_setSize(0);
     if ($options instanceof \Zend\Config\Config) {
         $options = $options->toArray();
     } elseif (is_scalar($options)) {
         $options = array('max' => $options);
     } elseif (!is_array($options)) {
         throw new \Zend\Validator\Exception\InvalidArgumentException('Invalid options to validator provided');
     }
     if (1 < func_num_args()) {
         $argv = func_get_args();
         array_shift($argv);
         $options['max'] = array_shift($argv);
         if (!empty($argv)) {
             $options['useByteString'] = array_shift($argv);
         }
     }
     parent::__construct($options);
 }