Level is not limited by table values, so has to be in code

@param int $levelValue
@throws \DrdPlus\Tables\Measurements\Experiences\Exceptions\MinLevelUnderflow
@throws \DrdPlus\Tables\Measurements\Experiences\Exceptions\MaxLevelOverflow
432805
private function guardLevelBoundaries($levelValue)
    {
        if ($levelValue < static::MIN_LEVEL) {
            throw new Exceptions\MinLevelUnderflow(
                'Level has to be at least ' . self::MIN_LEVEL . ', got ' . $levelValue
            );
        }
        if ($levelValue > static::MAX_LEVEL) {
            throw new Exceptions\MaxLevelOverflow(
                'Level can not be greater than ' . self::MAX_LEVEL . ', got ' . $levelValue
            );
        }
    }
397979
public function setLevel(int $level = 1) : CNabuDataObject
    {
        if ($level === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$level")
            );
        }
        $this->setValue('nb_site_map_level', $level);
        
        return $this;
    }
514114
protected function treeView(array $config, int $level = 0)
    {
        foreach ($config as $name => $value) {
            if (is_array($value)) {
                $this->writeln(
                    sprintf(
                        '%s<info>- %s</>:',
                        str_repeat(' ', $level * 2),
                        $name
                    )
                );

                if (count($value) > 0) {
                    $this->treeView($value, ++$level);
                    --$level;
                }
            } else {
                if (is_int($name)) {
                    $this->writeln(
                        sprintf(
                            '%s<info>- %s</>',
                            str_repeat(' ', $level * 2),
                            $value
                        )
                    );
                } else {
                    $this->writeln(
                        sprintf(
                            '%s<info>- %s</>: %s',
                            str_repeat(' ', $level * 2),
                            $name,
                            $value
                        )
                    );
                }
            }
        }
    }
1197499
public void setLevels(Level minLevel, Level maxLevel) throws IllegalArgumentException {
        if (minLevel != null && maxLevel != null && minLevel.intValue() > maxLevel.intValue()) {
            throw new IllegalArgumentException("Value of the minLevel parameter should specify level not larger than the value of the maxLevel parametere.");
        }
        this.minLevel = minLevel;
        this.maxLevel = maxLevel;
    }
799454
public function setPattern($patternValue) {
		$this->patternValue = $patternValue;
		if (isset($patternValue['patterns'])) {
			foreach ($patternValue['patterns'] as $patternConfiguration) {
				$requestPattern = $this->objectManager->get($this->requestPatternResolver->resolveRequestPatternClass($patternConfiguration['patternType']));
				$requestPattern->setPattern($patternConfiguration['patternValue']);
				$this->subPatterns[] = $requestPattern;
			}
		}
	}
1222879
public function setStocklevel( $stocklevel )
	{
		if ( $stocklevel === $this->getStocklevel() ) { return; }

		if ( $stocklevel !== null ) {
			$stocklevel = (int) $stocklevel;
		}

		$this->_values['stocklevel'] = $stocklevel;
		$this->setModified();
	}
938494
function(iCorrectLevel) {
			if( isNaN(iCorrectLevel) ) {
				throw new Error("Value " + iCorrectLevel + " is not a valid integer for Error Correction Level");
			}
			
			var correctLevel = parseInt(iCorrectLevel, 10);
			if( iCorrectLevel < 0 || iCorrectLevel > 3 ) {
				throw new Error("Value " + correctLevel + " is not a valid value for Error Correction Level (min 0, max 3)");
			}
			
			this.setProperty("correctLevel", correctLevel, false);
			return this;
		}
1234856
protected function _checkLogLevel( $level )
	{
		switch( $level )
		{
			case MW_Logger_Abstract::EMERG:
			case MW_Logger_Abstract::ALERT:
			case MW_Logger_Abstract::CRIT:
			case MW_Logger_Abstract::ERR:
			case MW_Logger_Abstract::WARN:
			case MW_Logger_Abstract::NOTICE:
			case MW_Logger_Abstract::INFO:
			case MW_Logger_Abstract::DEBUG:
				break;
			default:
				throw new MW_Logger_Exception( sprintf( 'Invalid log level constant "%1$d"', $level ) );
		}
	}
1015371
public function withLevel($level)
    {
        if (!isset(self::$levels[$level])) {
            throw new InvalidArgumentException('Unsupported log level "' . $level . '"');
        }

        $this->level = $level;
    }
1010832
public function setTransactionIsolationLevel($level = null)
    {
        $this->_connect();
        $sql = null;

        // Default transaction level in sql server
        if ($level === null)
        {
            $level = SQLSRV_TXN_READ_COMMITTED;
        }

        switch ($level) {
            case SQLSRV_TXN_READ_UNCOMMITTED:
                $sql = "READ UNCOMMITTED";
                break;
            case SQLSRV_TXN_READ_COMMITTED:
                $sql = "READ COMMITTED";
                break;
            case SQLSRV_TXN_REPEATABLE_READ:
                $sql = "REPEATABLE READ";
                break;
            case SQLSRV_TXN_SNAPSHOT:
                $sql = "SNAPSHOT";
                break;
            case SQLSRV_TXN_SERIALIZABLE:
                $sql = "SERIALIZABLE";
                break;
            default:
                // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
                throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified");
        }

        if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) {
            // require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
            throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'");
        }

        return true;
    }
194849
public function setSourceValue($sourceValue)
    {
        if (is_int($sourceValue)) {
            $this->sourceValue = $sourceValue;
        } else {
            $msg = "SourceValue must be an integer, '" . gettype($sourceValue) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
623045
public function ensureScopeRule(int $stackLevel = 2): void
    {
        $property    = $this->reflectionProperty;
        $isProtected = $property->isProtected();
        $isPrivate   = $property->isPrivate();
        if ($isProtected || $isPrivate) {
            $backTrace     = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $stackLevel+1);
            $accessor      = $backTrace[$stackLevel] ?? [];
            $propertyClass = $property->class;
            if (isset($accessor['class'])) {
                // For private and protected properties its ok to access from the same class
                if ($accessor['class'] === $propertyClass) {
                    return;
                }
                // For protected properties its ok to access from any subclass
                if ($isProtected && is_subclass_of($accessor['class'], $propertyClass)) {
                    return;
                }
            }
            throw new AspectException("Cannot access property {$propertyClass}::{$property->name}");
        }
    }
1295850
protected final void setLevel(int traceLevel) {

        switch (traceLevel) {
            case Trace.Level_All:
                debugEnabled = true;
                eventEnabled = true;
                entryEnabled = true;
                break;

            case Trace.Level_Entry:
                debugEnabled = false;
                eventEnabled = false;
                entryEnabled = true;
                break;

            case Trace.Level_Debug:
                debugEnabled = true;
                eventEnabled = false;
                entryEnabled = false;
                break;

            case Trace.Level_Event:
                debugEnabled = false;
                eventEnabled = true;
                entryEnabled = false;
                break;

            case Trace.Level_None:
                debugEnabled = false;
                eventEnabled = false;
                entryEnabled = false;
                break;

            default:
        } // switch (traceLevel).

    }
1164286
protected function validate_calculated_value($calculatedvalue) {

        // Using intval as it may come as a float from the db.
        if (!in_array(intval($calculatedvalue), static::get_classes())) {
            throw new \coding_exception(get_class($this) . ' calculated value "' . $calculatedvalue .
                '" is not one of its defined classes (' . json_encode(static::get_classes()) . ')');
        }
        return true;
    }
1128318
public function setDefaultValue($defaultValue)
    {
        if (!$defaultValue instanceof ColumnDefaultValue) {
            $defaultValue = new ColumnDefaultValue($defaultValue, ColumnDefaultValue::TYPE_VALUE);
        }

        $this->domain->setDefaultValue($defaultValue);
    }
292227
function setLevel(level) {
        if (typeof(level) === "number") {
            if (level >= 0 && level <= 5) {
                _level = level;
            } else {
                invalidParameter(level);
            }
        } else if (typeof(level) === 'string') {
            if (Level.hasOwnProperty(level)) {
                _level = Level[level];
            } else {
                invalidParameter(level);
            }
        } else {
            invalidParameter(level);
        }
        return createObject();
    }
908470
protected function getLevelColor($levelValue)
    {
        if ($levelValue >= Level::ERROR) {
            return 'red';
        }

        if ($levelValue >= Level::WARNING) {
            return 'yellow';
        }

        if ($levelValue === Level::DEBUG) {
            return 'grey';
        }

        return 'green';
    }