Gives highest level possible, independently on any previous level.

@param Experiences $experiences
@return Level
3172
public function toLevel(Experiences $experiences): Level
    {
        $woundsBonus = $this->toWoundsBonus($experiences);

        return new Level($this->bonusToLevelValue($woundsBonus), $this);
    }
1242759
public function migrateUp( $levels = NULL )
    {
        if ( NULL !== $levels )
        {
            $this->levels = $levels;
        }
        
        $newMigrations = $this->getNewMigrations( );
        
        $i = 0;
        
        if ( self::MIGRATE_ALL === $this->levels || $this->levels > count( $newMigrations ) )
        {
            $this->levels = count( $newMigrations );
        }
        
        while ( $i < $this->levels )
        {
            $class = $this->migrationNamespace . '\\' . $newMigrations[ $i ];
            
            if ( !class_exists( $class ) )
            {
                if ( !array_search( 'RawPHP\\RawMigrator\\Migrations\\', $this->namespaces, TRUE ) )
                {
                    $this->namespaces[] = 'RawPHP\\RawMigrator\\Migrations\\';
                }
                
                foreach( $this->namespaces as $ns )
                {
                    $cls = $ns . $newMigrations[ $i ];
                    
                    if ( class_exists( $cls ) )
                    {
                        $class = $cls;
                        
                        break;
                    }
                }
                
                if ( NULL === $class )
                {
                    throw new MigrationException( 'Migration class: ' . $class . ' - not found' );
                }
            }
            
            $migration = new $class( );
            
            $method = new \ReflectionMethod( $class, 'migrateUp' );
            
            // run migrateUp
            if ( $class === $method->getdeclaringClass()->name )
            {
                $migration->migrateUp( $this->db );
                
                $this->_addMigrationRecord( $class );
            }
            else
            {
                $method = new \ReflectionMethod( $class, 'safeMigrateUp' );
                
                if ( $class === $method->getDeclaringClass()->name )
                {
                    try
                    {
                        $this->db->startTransaction( );
                        
                        // turn off auto commit
                        $this->db->setTransactionAutocommit( FALSE );
                        
                        // run safeMigrateUp
                        $migration->safeMigrateUp( $this->db );
                        
                        // update migrations table with the new applied migration
                        $this->_addMigrationRecord( $class );
                        
                        // commit transaction
                        $this->db->commitTransaction( );
                    }
                    catch ( Exception $e )
                    {
                        // roleback transaction
                        $this->db->rollbackTransaction( );
                        
                        throw $e;
                    }
                }
            }
            
            $i++;
            
            if ( $this->levels === $i )
            {
                $this->doAction( self::ON_MIGRATE_UP_ACTION );
                
                return;
            }
        }
    }
258049
protected static function create_level_instances() {
        global $DB;

        $sql = "SELECT ".CONTEXT_COURSECAT.", cc.id
                  FROM {course_categories} cc
                 WHERE NOT EXISTS (SELECT 'x'
                                     FROM {context} cx
                                    WHERE cc.id = cx.instanceid AND cx.contextlevel=".CONTEXT_COURSECAT.")";
        $contextdata = $DB->get_recordset_sql($sql);
        foreach ($contextdata as $context) {
            context::insert_context_record(CONTEXT_COURSECAT, $context->id, null);
        }
        $contextdata->close();
    }
681600
public function migrateDown( $levels = NULL )
    {
        if ( NULL !== $levels )
        {
            $this->levels = $levels;
        }
        
        $migrations = $this->getAppliedMigrations( );
        
        $i = 0;
        
        if ( self::MIGRATE_ALL === $this->levels || $this->levels > count( $migrations ) )
        {
            $this->levels = count( $migrations );
        }
        
        while ( $i < $this->levels )
        {
            $class = $migrations[ $i ];
            
            $migration = new $class( );
            
            $method = new \ReflectionMethod( $class, 'migrateDown' );
            
            // run migrateDown
            if ( $class === $method->getDeclaringClass( )->name )
            {
                $migration->migrateDown( $this->db );
                
                // delete migration from table
                if ( FALSE === $this->_deleteMigrationRecord( $class ) )
                {
                    throw new MigrationException( 'Failed to delete migration record: ' . $class );
                }
            }
            else // run safeMigrateDown
            {
                $method = new \ReflectionMethod( $class, 'safeMigrateDown' );
            
                if ( $class === $method->getDeclaringClass( )->name )
                {
                    try
                    {
                        // start transaction
                        $this->db->startTransaction( );

                        // turn off auto commit
                        $this->db->setTransactionAutocommit( FALSE );

                        // run safeMigrateDown
                        $migration->safeMigrateDown( $this->db );

                        // delete migration record
                        if ( FALSE === $this->_deleteMigrationRecord( $class ) )
                        {
                            throw new MigrationException( 
                                    'Failed to delete migration record: ' . $class );
                            
                            $this->db->rollbackTransaction();
                        }

                        // commit transaction
                        $this->db->commitTransaction( );
                    }
                    catch ( \Exception $e )
                    {
                        // rollback transaction
                        $this->db->rollbackTransaction( );

                        throw $e;
                    }
                }
            }
            
            $i++;
            
            if ( $this->levels === $i )
            {
                $this->doAction( self::ON_MIGRATE_DOWN_ACTION );
                
                return;
            }
        }
    }
106718
public static function top() {
        if (!isset(self::$coursecat0)) {
            $record = new stdClass();
            $record->id = 0;
            $record->visible = 1;
            $record->depth = 0;
            $record->path = '';
            $record->locked = 0;
            self::$coursecat0 = new self($record);
        }
        return self::$coursecat0;
    }
48244
public function multiLevelCount()
    {
        $levelCount = 0;
        foreach ($this->dataValues as $dataValueSet) {
            $levelCount = max($levelCount, count($dataValueSet));
        }
        return $levelCount;
    }
117194
public function multiLevelCount() {
		$levelCount = 0;
		foreach($this->_dataValues as $dataValueSet) {
			$levelCount = max($levelCount,count($dataValueSet));
		}
		return $levelCount;
	}
419386
protected function last()
    {
        $i = count($this->env->children) - 1;

        if (isset($this->env->children[$i])) {
            return $this->env->children[$i];
        }
    }
1159203
protected function isPropertyAccessibilityLevelValid(int $level) : bool
    {
        if ($level == AccessibilityLevels::PUBLIC_LEVEL ||
            $level ==  AccessibilityLevels::PROTECTED_LEVEL ||
            $level == AccessibilityLevels::PRIVATE_LEVEL
        ) {
            return true;
        }

        return false;
    }
728725
public static function hasLevel(int $level=null) :bool {
		// if we have said level
		return self::$_account ? 
			self::getAccount()->hasLevel($level) : false;
	}
889526
public function actionLevelUp()
    {
        Yii::$app->session->set(Update::SESSION_KEY, 0);

        $error = '';
        $info = '';
        $dbVersion = 0;
        $mdVersion = $this->module->version;
        $dbQuery = (new Query())->from('{{%podium_config}}')->select('value')->where(['name' => 'version'])->limit(1)->one();
        if (!isset($dbQuery['value'])) {
            $error = Yii::t('podium/flash', 'Error while checking current database version! Please verify your database.');
        } else {
            $dbVersion = $dbQuery['value'];
            $result = Helper::compareVersions(explode('.', $mdVersion), explode('.', $dbVersion));
            if ($result == '=') {
                $info = Yii::t('podium/flash', 'Module and database versions are the same!');
            } elseif ($result == '<') {
                $error = Yii::t('podium/flash', 'Module version appears to be older than database! Please verify your database.');
            }
        }

        Yii::$app->session->set(Update::SESSION_VERSION, $dbVersion);

        return $this->render('level-up', [
            'currentVersion' => $mdVersion,
            'dbVersion' => $dbVersion,
            'error' => $error,
            'info' => $info
        ]);
    }
1216438
private int getLevel(final Level recordLevel) {
    if (recordLevel.equals(Level.OFF)) {
      return 0;
    } else if (recordLevel.equals(Level.SEVERE)) {
      return 1;
    } else if (recordLevel.equals(Level.WARNING)) {
      return 2;
    } else if (recordLevel.equals(Level.ALL)) {
      return 4;
    } else {
      return 3;
    }
  }
137349
protected function getPage($records, $maxshown, $numpages) {
        $show = floor($numpages / 2);
        if (self::$lastpage > $numpages) {
            self::$page = (self::$current > $show ? (self::$current - $show) : 1);
            if (self::$current < (self::$lastpage - $show)) {
                self::$lastpage = ((self::$current <= $show) ? (self::$current + ($numpages - self::$current)) : (self::$current + $show));
            }
            else { self::$page = self::$current - ($numpages - ((ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)) - self::$current)) - 1); }
        }
        else { self::$page = 1; }
    }
33514
public function xpTolevel($xp)
    {
        $modifier = 0;

        for ($i = 1; $i <= 126; $i++) {
            $modifier += floor($i + 300 * pow(2, ($i / 7)));
            $level = floor($modifier / 4);

            if ($xp < $level) {
                return $i;
            }
        }

        // Return the maximum possible level
        return 126;
    }
1136672
public function getDescendantsAndSelf( $columns = ['*'] )
	{
		if ( is_array( $columns ) )
			return $this->descendantsAndSelf()->get( $columns );

		$arguments = func_get_args();

		$limit = intval( array_shift( $arguments ) );
		$columns = array_shift( $arguments ) ?: ['*'];

		return $this->descendantsAndSelf()->limitDepth( $limit )->get( $columns );
	}
862134
protected function maxDepthFromRelations(array $relations)
    {

        if (!$relations) {
            return 1;
        }

        $max = 1;

        foreach ($relations as $path) {
            $max = max($max, count(explode('.', $path)));
        }

        // max has to be relation depth +1 because we want to have the
        // keys of that relation too
        return (int)$max + 1;

    }
122663
public function level($level)
    {
        if (empty($level)) {
            $level = [];
        } elseif (is_string($level)) {
            $level = explode(',', str_replace(' ', '', $level));
        } else {
            $level = is_array($level) ? $level : func_get_args();
        }

        $this->setLevel($level);

        return $this;
    }