| Conditions | 9 |
| Paths | 21 |
| Total Lines | 36 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 9.0101 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | } |
||
| 17 | |||
| 18 | 3 | public function getCssClass(): string |
|
| 19 | { |
||
| 20 | 3 | $class = 'module_selector'; |
|
| 21 | |||
| 22 | 3 | if ($this->moduleSelector->getAvailableModules() === []) { |
|
| 23 | 3 | return $class; |
|
| 24 | } |
||
| 25 | |||
| 26 | 3 | if ($this->moduleSelector->allowEmptySlot()) { |
|
| 27 | |||
| 28 | 3 | if ($this->moduleSelector->isEmptySlot()) { |
|
| 29 | $class .= ' module_selector_skipped'; |
||
| 30 | 3 | } elseif (!$this->moduleSelector->hasSelectedModule()) { |
|
| 31 | 1 | $class .= self::UNSELECTED_CLASS; |
|
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | 3 | if ($this->moduleSelector->isMandatory()) { |
|
| 36 | |||
| 37 | 3 | $buildplan = $this->moduleSelector->getBuildplan(); |
|
| 38 | |||
| 39 | 3 | if (!$this->moduleSelector->hasSelectedModule()) { |
|
| 40 | 1 | $class .= self::UNSELECTED_CLASS; |
|
| 41 | 2 | } elseif ($buildplan !== null) { |
|
| 42 | |||
| 43 | /** @var Module $mod */ |
||
| 44 | 2 | $mod = $buildplan->getModulesByType($this->moduleSelector->getModuleType())->first(); |
|
| 45 | 2 | $commodityId = $mod->getCommodityId(); |
|
| 46 | |||
| 47 | 2 | $stor = $this->moduleSelector->getHost()->getStorage()[$commodityId] ?? null; |
|
| 48 | 2 | if ($stor === null) { |
|
| 49 | 2 | $class .= self::UNSELECTED_CLASS; |
|
| 50 | } |
||
| 51 | } |
||
| 52 | } |
||
| 56 |