Lines
100.00%
5 / 5
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ExcludeIds | 100.00% | 5 / 5 | 100.00% | 2 / 2 | 4 | 100.00% | 1 / 1 | |||
| fromQuery | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 3 | |||||
| toQuery | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace BO\Zmsadmin\Helper; | |
| 6 | ||
| 7 | /** | |
| 8 | * Queue exclude numbers are CSV on the HTTP wire; use arrays inside PHP. | |
| 9 | */ | |
| 10 | class ExcludeIds | |
| 11 | { | |
| 12 | public static function fromQuery(?string $exclude): array | |
| 13 | { | |
| 14 | if ($exclude === null || $exclude === '') { | |
| 15 | return []; | |
| 16 | } | |
| 17 | ||
| 18 | $ids = array_map('trim', explode(',', $exclude)); | |
| 19 | return array_values(array_filter($ids, static fn(string $id): bool => $id !== '')); | |
| 20 | } | |
| 21 | ||
| 22 | public static function toQuery(array $exclude): string | |
| 23 | { | |
| 24 | return implode(',', $exclude); | |
| 25 | } | |
| 26 | } |