| Conditions | 5 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | function orList(array $items): string |
||
| 14 | { |
||
| 15 | $selected = \array_slice($items, 0, MAX_LENGTH); |
||
| 16 | $count = \count($selected); |
||
| 17 | $index = 0; |
||
| 18 | |||
| 19 | return $count === 1 |
||
| 20 | ? $selected[0] |
||
| 21 | : array_reduce($selected, function ($list, $item) use ($count, &$index) { |
||
| 22 | $list .= ($index > 0 && $index < ($count - 1) ? ', ' : '') . ($index === ($count - 1) ? ' or ' : '') . |
||
| 23 | $item; |
||
| 24 | $index++; |
||
| 25 | return $list; |
||
| 26 | }, ''); |
||
| 27 | } |
||
| 41 |