Sets the maximum file count

@param  integer|array $max The maximum file count
@return Zend_Validate_StringLength Provides a fluent interface
@throws Zend_Validate_Exception When max is smaller than min
334164
public function setMax($max)
    {
        if (is_array($max) and isset($max['max'])) {
            $max = $max['max'];
        }

        if (!is_string($max) and !is_numeric($max)) {
            // require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception ('Invalid options to validator provided');
        }

        $max = (integer) $max;
        if (($this->_min !== null) && ($max < $this->_min)) {
            // require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but "
                                            . "$max < {$this->_min}");
        }

        $this->_max = $max;
        return $this;
    }
410932
public function setMaxFileSize(int $value)
    {
        $this->maxFileSize = $value;

        $this->addValidationRule('max:' . $this->maxFileSize);

        return $this;
    }
60092
public function setMaxQueryTime($max)
    {
        assert(is_int($max));
        assert($max >= 0);
        $this->_maxquerytime = $max;

        return $this;
    }
996673
public function setMax($max)
    {
        if (is_numeric($max) || Format::isVariableRef($max)) {
            $this->max = $max;
        } else {
            $msg = "'Max must be a numeric value or a variableRef, '" . gettype($max) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
186025
public function length($min = null, $max = null)
	{
		$lastSegmentKey = $this->getLastSegmentKey();

		if (!is_null($min) && !is_null($max) && $max > $min)
		{
			$lengthPattern = sprintf('{%d,%d}', (int) $min, (int) $max);
		}
		elseif (!is_null($min) && !$max)
		{
			$lengthPattern = sprintf('{%d}', (int) $min);
		}
		else
		{
			$lengthPattern = '{1}';
		}

		return $this->replaceQuantifierByKey($lastSegmentKey, $lengthPattern);
	}
281667
public static function length($val, $min, $max = null)
    {
        return isset($val[$min - 1]) && (null === $max || !isset($val[$max]));
    }
207153
public function vLimit(Int $min = 0, Int $max = NULL)
    {
        $key['minchar'] = [':p1' => $min];
        $typ['minchar'] = $min;

        if( $max !== NULL )
        {
            $key['maxchar'] = [':p1' => $max];
            $typ['maxchar'] = $max;
        }

        return $this->onInvalidEventPattern('.{' . $min . ',' . $max . '}', $key, [], $typ);
    }
970346
public function setMaximum($maximum)
    {
        if (!\in_array($this->type, [self::TYPE_INTEGER, self::TYPE_NUMBER], true)) {
            throw new \Exception('maximum can only be set on type "integer" or "number');
        }

        $this->maximum = (int) $maximum;
    }
114394
public function setMaxFileSize(int $maxFileSize)
    {
        if ($maxFileSize > 0) {
            $properties = $this->getProperties();
            $properties['maxFileSize'] = $maxFileSize;
            $this->setProperties($properties);
            return $this;
        }
        return false;
    }
1064054
public function length($min, $max = null) {
        if (!$this->_isValid) {
            return $this;
        }
        $length = mb_strlen($this->_unsafeVar, $this->conf['encoding']);
        if ($length < $min || (!is_null($max) && $length > $max)) {
            $this->_isValid = false;
        }
        return $this;
    }
326696
public function setMaxLineLength(int $maxLineLength): Message
    {
        // Each line of characters MUST be no more than 998 characters,
        // and SHOULD be no more than 78 characters, excluding the CRLF.
        // https://tools.ietf.org/html/rfc5322#section-2.1.1
        $maxLineLength = (int) abs($maxLineLength);

        if ($maxLineLength > 998) {
            $maxLineLength = 998;
        }

        $this->maxLineLength = $maxLineLength;

        return $this;
    }
76993
public function setMax($max) : self
    {
        if (null === $max || (!is_float($max) && !is_int($max))) {
            throw new \InvalidArgumentException('max must be either a float or an integer.');
        }

        $this->max = $max;

        return $this;
    }
1302854
function setMaxFileSize($bytes = 0)
    {
        if ($bytes > 0) {
            $this->_maxFileSize = $bytes;
        }
        if (!$this->elementExists('MAX_FILE_SIZE')) {
            $this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize);
        } else {
            $el =& $this->getElement('MAX_FILE_SIZE');
            $el->updateAttributes(array('value' => $this->_maxFileSize));
        }
    }
885513
public function setMaxTimeReservation($maxTime)
    {
        if (!$maxTime || empty($maxTime)) {
            $maxTime = '00:00:00';
        } elseif (count(explode(':', $maxTime)) === 2) {
            $maxTime = $maxTime.':00';
        }

        $this->maxTimeReservation = $maxTime;

        return $this;
    }
1165929
public function setMaxFileSize($fileSize, $unit = 'M')
    {
        switch ($unit) {
            case 'B':
                $fileSize = (int)$fileSize;
                break;
            case 'K':
                $fileSize = (int)$fileSize * 1000;
                break;
            case 'M':
                $fileSize = (int)$fileSize * 1000000;
                break;
            case 'G':
                $fileSize = (int)$fileSize * 1000000000;
                break;
        }

        $this->allowedFileSize[ 'max' ] = (int)$fileSize;

        return $this;
    }
163393
public function setMax(?string $max) : self
    {
        if ($max !== null) {
            $max = Decimal::parse($max);
        }

        $this->max = $max;

        return $this;
    }
1324889
function setMaxbytes($maxbytes) {
        global $CFG, $PAGE;
        $this->_options['maxbytes'] = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $maxbytes);
    }