Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Trim | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| apply | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| safe | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Boiler\Filter; |
| 6 | |
| 7 | use Celemas\Boiler\Contract; |
| 8 | use Override; |
| 9 | |
| 10 | /** @api */ |
| 11 | final class Trim implements Contract\Filter, Contract\PreservesSafety |
| 12 | { |
| 13 | #[Override] |
| 14 | public function apply(string $value, mixed ...$args): string |
| 15 | { |
| 16 | if (!array_key_exists(0, $args) || $args[0] === null) { |
| 17 | return trim($value); |
| 18 | } |
| 19 | |
| 20 | return trim($value, (string) $args[0]); |
| 21 | } |
| 22 | |
| 23 | #[Override] |
| 24 | public function safe(): bool |
| 25 | { |
| 26 | return false; |
| 27 | } |
| 28 | } |