| Conditions | 5 |
| Paths | 7 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function getAction(string $stepName, string $manager = null): StepActionInterface |
||
| 29 | { |
||
| 30 | if (!$this->actions) { |
||
|
|
|||
| 31 | throw new \RuntimeException('No actions in the registry.'); |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($manager === null) { |
||
| 35 | $manager = array_keys($this->actions)[0]; |
||
| 36 | } |
||
| 37 | |||
| 38 | if (!isset($this->actions[$manager])) { |
||
| 39 | throw new \InvalidArgumentException(\sprintf( |
||
| 40 | 'Manager "%s" does not exist.', |
||
| 41 | $manager |
||
| 42 | )); |
||
| 43 | } |
||
| 44 | |||
| 45 | if (!isset($this->actions[$manager][$stepName])) { |
||
| 46 | throw new \InvalidArgumentException(\sprintf( |
||
| 47 | 'Step "%s" not found in manager "%s".', |
||
| 48 | $stepName, $manager |
||
| 49 | )); |
||
| 50 | } |
||
| 51 | |||
| 52 | return $this->actions[$manager][$stepName]; |
||
| 53 | } |
||
| 54 | } |
||
| 55 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.