| Conditions | 6 |
| Paths | 10 |
| Total Lines | 29 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 2 | public function addExpertise( |
|
| 18 | SpacecraftInterface|SpacecraftWrapperInterface $target, |
||
| 19 | SkillEnhancementEnum $trigger, |
||
| 20 | int $percentage |
||
| 21 | ): void { |
||
| 22 | |||
| 23 | 2 | $spacecraft = $target instanceof SpacecraftInterface ? $target : $target->get(); |
|
| 24 | |||
| 25 | 2 | $enhancements = $this->skillEnhancementCache->getSkillEnhancements($trigger); |
|
| 26 | 2 | if ($enhancements === null) { |
|
| 27 | 1 | return; |
|
| 28 | } |
||
| 29 | |||
| 30 | 1 | foreach ($spacecraft->getCrewAssignments() as $crewAssignment) { |
|
| 31 | 1 | $position = $crewAssignment->getPosition(); |
|
| 32 | 1 | if ($position === null) { |
|
| 33 | 1 | continue; |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | if (!array_key_exists($position->value, $enhancements)) { |
|
| 37 | 1 | continue; |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | $this->raiseExpertise->raiseExpertise( |
|
| 41 | 1 | $crewAssignment->getCrew(), |
|
| 42 | 1 | $spacecraft, |
|
| 43 | 1 | $position, |
|
| 44 | 1 | $enhancements[$position->value], |
|
| 45 | 1 | $percentage |
|
| 46 | 1 | ); |
|
| 50 |