public function getNewValue(int $maxValue, int $changeValue, string $progressType)
    {
        switch ($progressType) {
            case AchievementCriteriaChange::PROGRESS_SET:
                $newValue = $changeValue;
                break;
            case AchievementCriteriaChange::PROGRESS_ACCUMULATE:
                $newValue = $this->value + $changeValue;

                if ($maxValue > 0) {
                    $newValue = $maxValue - $this->value > $changeValue ? $this->value + $changeValue : $maxValue;
                }
                break;
            case AchievementCriteriaChange::PROGRESS_HIGHEST:
                $newValue = $this->value < $changeValue ? $changeValue : $this->value;
                break;
            default:
                throw new \InvalidArgumentException('Given progress type is invalid ('.$progressType.').');
        }

        return $newValue;
    }
public function getNewValue(int $maxValue, int $changeValue, string $progressType)
    {
        switch ($progressType) {
            case AchievementCriteriaChange::PROGRESS_SET:
                $newValue = $changeValue;
                break;
            case AchievementCriteriaChange::PROGRESS_ACCUMULATE:
                $newValue = $this->value + $changeValue;

                if ($maxValue > 0) {
                    $newValue = $maxValue - $this->value > $changeValue ? $this->value + $changeValue : $maxValue;
                }
                break;
            case AchievementCriteriaChange::PROGRESS_HIGHEST:
                $newValue = $this->value < $changeValue ? $changeValue : $this->value;
                break;
            default:
                throw new \InvalidArgumentException('Given progress type is invalid ('.$progressType.').');
        }

        return $newValue;
    }
public function getNewValue ( int $ maxValue , int $ changeValue , string $ progressType ) { switch ( $ progressType ) { case AchievementCriteriaChange :: PROGRESS_SET : $ newValue = $ changeValue ; break ; case AchievementCriteriaChange :: PROGRESS_ACCUMULATE : $ newValue = $ this -> value + $ changeValue ; if ( $ maxValue > 0 ) { $ newValue = $ maxValue - $ this -> value > $ changeValue ? $ this -> value + $ changeValue : $ maxValue ; } break ; case AchievementCriteriaChange :: PROGRESS_HIGHEST : $ newValue = $ this -> value < $ changeValue ? $ changeValue : $ this -> value ; break ; default : throw new \ InvalidArgumentException ( 'Given progress type is invalid (' . $ progressType . ').' ) ; } return $ newValue ; }
Calculates new progress value.

@param int    $maxValue
@param int    $changeValue
@param string $progressType

@throws \InvalidArgumentException

@return int
Calculates new progress value .