Conditions | 7 |
Paths | 7 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
54 | public function getNewValue(int $maxValue, int $changeValue, string $progressType) |
||
55 | { |
||
56 | switch ($progressType) { |
||
57 | case AchievementCriteriaChange::PROGRESS_SET: |
||
58 | $newValue = $changeValue; |
||
59 | break; |
||
60 | case AchievementCriteriaChange::PROGRESS_ACCUMULATE: |
||
61 | $newValue = $this->value + $changeValue; |
||
62 | |||
63 | if ($maxValue > 0) { |
||
64 | $newValue = $maxValue - $this->value > $changeValue ? $this->value + $changeValue : $maxValue; |
||
65 | } |
||
66 | break; |
||
67 | case AchievementCriteriaChange::PROGRESS_HIGHEST: |
||
68 | $newValue = $this->value < $changeValue ? $changeValue : $this->value; |
||
69 | break; |
||
70 | default: |
||
71 | throw new \InvalidArgumentException('Given progress type is invalid ('.$progressType.').'); |
||
72 | } |
||
73 | |||
74 | return $newValue; |
||
75 | } |
||
76 | } |
||
77 |