Conditions | 9 |
Paths | 1 |
Total Lines | 32 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 9 |
Changes | 0 |
1 | <?php |
||
23 | 3 | public function getDataTransformer(): ?\Closure |
|
24 | { |
||
25 | 1 | return function ($data) { |
|
26 | if ($data === null) { |
||
27 | 1 | return ''; |
|
28 | 1 | } |
|
29 | 1 | ||
30 | if (\is_string($data)) { |
||
31 | return $data; |
||
32 | 1 | } |
|
33 | 1 | ||
34 | if (is_numeric($data)) { |
||
35 | return (string) $data; |
||
36 | 1 | } |
|
37 | 1 | ||
38 | if (\is_array($data)) { |
||
39 | return implode(',', $data); |
||
40 | 1 | } |
|
41 | 1 | ||
42 | if ($data instanceof \DateTimeInterface) { |
||
43 | return $data->format($this->getOption('date_format')); |
||
44 | 1 | } |
|
45 | 1 | ||
46 | if ($data instanceof Collection) { |
||
47 | return implode(',', $data->toArray()); |
||
48 | 1 | } |
|
49 | 1 | ||
50 | if (\is_object($data) && method_exists($data, '__toString')) { |
||
51 | return (string) $data; |
||
52 | 1 | } |
|
53 | 1 | ||
54 | return ''; |
||
55 | }; |
||
58 |