Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| FlattensValues | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |
0.00% |
0 / 1 |
| toSingleValue | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
| 1 | <?php |
| 2 | namespace Apie\Export\Concerns; |
| 3 | |
| 4 | use Apie\Core\ValueObjects\Utils; |
| 5 | use UnitEnum; |
| 6 | |
| 7 | trait FlattensValues |
| 8 | { |
| 9 | private function toSingleValue(mixed $input): string|int|float|bool|null |
| 10 | { |
| 11 | $input = Utils::toNative($input); |
| 12 | if ($input instanceof UnitEnum) { |
| 13 | return $input->name; |
| 14 | } |
| 15 | if (is_array($input)) { |
| 16 | return implode(', ', array_map([$this, 'toSingleValue'], $input)); |
| 17 | } |
| 18 | |
| 19 | return $input; |
| 20 | } |
| 21 | } |