public function toTotalLevel(Experiences $experiences): Level
    {
        $currentExperiences = 0;
        $usedExperiences = 0;
        $maxLevelValue = 0;
        while ($usedExperiences + $currentExperiences <= $experiences->getValue()) {
            $level = $this->toLevel(new Experiences($currentExperiences, $this));
            if ($maxLevelValue < $level->getValue()) {
                $usedExperiences += $currentExperiences;
                $maxLevelValue = $level->getValue();
            }
            $currentExperiences++;
        }

        return new Level($maxLevelValue, $this);
    }
public function toTotalLevel(Experiences $experiences): Level
    {
        $currentExperiences = 0;
        $usedExperiences = 0;
        $maxLevelValue = 0;
        while ($usedExperiences + $currentExperiences <= $experiences->getValue()) {
            $level = $this->toLevel(new Experiences($currentExperiences, $this));
            if ($maxLevelValue < $level->getValue()) {
                $usedExperiences += $currentExperiences;
                $maxLevelValue = $level->getValue();
            }
            $currentExperiences++;
        }

        return new Level($maxLevelValue, $this);
    }
public function toTotalLevel ( Experiences $ experiences ) : Level { $ currentExperiences = 0 ; $ usedExperiences = 0 ; $ maxLevelValue = 0 ; while ( $ usedExperiences + $ currentExperiences <= $ experiences -> getValue ( ) ) { $ level = $ this -> toLevel ( new Experiences ( $ currentExperiences , $ this ) ) ; if ( $ maxLevelValue < $ level -> getValue ( ) ) { $ usedExperiences += $ currentExperiences ; $ maxLevelValue = $ level -> getValue ( ) ; } $ currentExperiences ++ ; } return new Level ( $ maxLevelValue , $ this ) ; }
Leveling sequentially from very first level up to highest possible until all experiences are spent.

@param Experiences $experiences
@return Level
Leveling sequentially from very first level up to highest possible until all experiences are spent .