1 | <?php declare(strict_types=1); |
||
14 | class ValueFormatter |
||
15 | { |
||
16 | /** |
||
17 | * Evaluates if the given value is to be treated as empty. |
||
18 | * |
||
19 | * @param mixed $value |
||
20 | * |
||
21 | * @return bool |
||
22 | */ |
||
23 | 3 | public function isValueEmpty($value) |
|
27 | |||
28 | /** |
||
29 | * Get $value if not empty, $defaultValue otherwise. |
||
30 | * |
||
31 | * @param mixed $value |
||
32 | * @param mixed|null $defaultValue |
||
33 | * |
||
34 | * @return mixed|null |
||
35 | */ |
||
36 | 2 | public function getValue($value, $defaultValue = null) |
|
44 | |||
45 | /** |
||
46 | * Get formatted value base on type and format. |
||
47 | * |
||
48 | * @param string $type |
||
49 | * @param string $format |
||
50 | * @param mixed $value |
||
51 | * @param mixed|null $defaultValue |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | 1 | public function format($type, $format, $value, $defaultValue = null) |
|
65 | |||
66 | /** |
||
67 | * Format Integer. |
||
68 | * |
||
69 | * @return int |
||
70 | */ |
||
71 | 1 | private function formatInteger() |
|
77 | |||
78 | /** |
||
79 | * Format Float. |
||
80 | * |
||
81 | * @return float |
||
82 | */ |
||
83 | 1 | private function formatFloat() |
|
89 | |||
90 | /** |
||
91 | * Format String. |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | 1 | private function formatString() |
|
101 | |||
102 | /** |
||
103 | * Format Boolean. |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | 1 | private function formatBoolean() |
|
113 | |||
114 | /** |
||
115 | * Format Number. |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | 1 | private function formatNumber() |
|
134 | |||
135 | /** |
||
136 | * Format Datetime. |
||
137 | * |
||
138 | * @return \DateTime|string|bool |
||
139 | */ |
||
140 | 1 | private function formatDatetime() |
|
158 | } |
||
159 |