Total Complexity | 5 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 75% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | trait GenericHelper |
||
13 | { |
||
14 | /** |
||
15 | * @param string $value |
||
16 | * @return null|DateTimeInterface |
||
17 | */ |
||
18 | 1 | protected function convertToDateTime(string $value): ?DateTimeInterface |
|
19 | { |
||
20 | try { |
||
21 | 1 | return new DateTimeImmutable($value); |
|
22 | } catch (Throwable $e) { |
||
23 | return null; |
||
24 | } |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param string $value |
||
29 | * @return bool |
||
30 | */ |
||
31 | 1 | protected function convertToBoolean(string $value): bool |
|
32 | { |
||
33 | 1 | return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param null|string $string |
||
38 | * @return null|string |
||
39 | */ |
||
40 | 17 | protected function emptyStringAsNull(?string $string): ?string |
|
43 | } |
||
44 | } |
||
45 |