Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
11 / 11 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Strings | |
100.00% |
11 / 11 |
|
100.00% |
3 / 3 |
6 | |
100.00% |
1 / 1 |
toArray | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
clean | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
split | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Projom\Util; |
6 | |
7 | class Strings |
8 | { |
9 | public static function toArray(string $subject, string $delimeter = ','): array |
10 | { |
11 | if (!$subject) |
12 | return []; |
13 | |
14 | $list = [$subject]; |
15 | if (strpos($subject, $delimeter) !== false) |
16 | $list = static::split($subject, $delimeter); |
17 | return $list; |
18 | } |
19 | |
20 | public static function clean(string $subject, string $remove = ' '): string |
21 | { |
22 | return str_replace($remove, '', $subject); |
23 | } |
24 | |
25 | public static function split(string $subject, string $delimeter = ','): array |
26 | { |
27 | if (!$subject) |
28 | return []; |
29 | |
30 | $result = explode($delimeter, $subject); |
31 | |
32 | return $result; |
33 | } |
34 | } |