Zend_Validate_StringLength::__construct PHP Méthode

__construct() public méthode

Sets validator options
public __construct ( integer | array | Zend_Config $options = [] )
$options integer | array | Zend_Config
    public function __construct($options = array())
    {
        if ($options instanceof Zend_Config) {
            $options = $options->toArray();
        } else {
            if (!is_array($options)) {
                $options = func_get_args();
                $temp['min'] = array_shift($options);
                if (!empty($options)) {
                    $temp['max'] = array_shift($options);
                }
                if (!empty($options)) {
                    $temp['encoding'] = array_shift($options);
                }
                $options = $temp;
            }
        }
        if (!array_key_exists('min', $options)) {
            $options['min'] = 0;
        }
        $this->setMin($options['min']);
        if (array_key_exists('max', $options)) {
            $this->setMax($options['max']);
        }
        if (array_key_exists('encoding', $options)) {
            $this->setEncoding($options['encoding']);
        }
    }

Usage Example

Exemple #1
0
 /**
  * Sets validator options
  *
  * @param  integer|array|Zend_Config $options
  */
 public function __construct($options = array())
 {
     if (!is_array($options)) {
         $options = func_get_args();
         if (!isset($options[1])) {
             $options[1] = 'utf-8';
         }
         parent::__construct($options[0], $options[0], $options[1]);
         return;
     } else {
         if (isset($options['length'])) {
             $options['max'] = $options['min'] = $options['length'];
         }
         if (isset($options['name'])) {
             $this->_name = $options['name'];
         }
     }
     parent::__construct($options);
 }
All Usage Examples Of Zend_Validate_StringLength::__construct