public function toTotalExperiences(Level $level): Experiences
    {
        $experiencesSum = 0;
        for ($levelValueToCast = $level->getValue(); $levelValueToCast > 0; $levelValueToCast--) {
            if ($levelValueToCast > 1) { // main profession has first level for free
                $currentLevel = new Level($levelValueToCast, $this);
                $experiencesSum += $currentLevel->getExperiences()->getValue();
            }
        }

        return new Experiences($experiencesSum, $this);
    }
public function toTotalExperiences(Level $level): Experiences
    {
        $experiencesSum = 0;
        for ($levelValueToCast = $level->getValue(); $levelValueToCast > 0; $levelValueToCast--) {
            if ($levelValueToCast > 1) { // main profession has first level for free
                $currentLevel = new Level($levelValueToCast, $this);
                $experiencesSum += $currentLevel->getExperiences()->getValue();
            }
        }

        return new Experiences($experiencesSum, $this);
    }
public function toTotalExperiences ( Level $ level ) : Experiences { $ experiencesSum = 0 ; for ( $ levelValueToCast = $ level -> getValue ( ) ; $ levelValueToCast > 0 ; $ levelValueToCast -- ) { if ( $ levelValueToCast > 1 ) { // main profession has first level for free $ currentLevel = new Level ( $ levelValueToCast , $ this ) ; $ experiencesSum += $ currentLevel -> getExperiences ( ) -> getValue ( ) ; } } return new Experiences ( $ experiencesSum , $ this ) ; }
Casting level to experiences is mostly lossy conversion!
Gives all experiences needed to achieve all levels sequentially up to given.

@param Level $level
@return Experiences
Casting level to experiences is mostly lossy conversion! Gives all experiences needed to achieve all levels sequentially up to given .