1 | <?php |
||
7 | class SchemaFormatter |
||
8 | { |
||
9 | /** |
||
10 | * Format a value by a registered format name |
||
11 | * |
||
12 | * @param string $format Registered format used to format the value |
||
13 | * @param mixed $value Value being formatted |
||
14 | * |
||
15 | * @return mixed |
||
16 | */ |
||
17 | 18 | public function format($format, $value) |
|
36 | |||
37 | /** |
||
38 | * Perform the actual DateTime formatting |
||
39 | * |
||
40 | * @param int|string|\DateTime $dateTime Date time value |
||
41 | * @param string $format Format of the result |
||
42 | * |
||
43 | * @return string |
||
44 | * @throws \InvalidArgumentException |
||
45 | */ |
||
46 | 13 | protected function dateFormatter($dateTime, $format) |
|
67 | |||
68 | /** |
||
69 | * Create a ISO 8601 (YYYY-MM-DDThh:mm:ssZ) formatted date time value in |
||
70 | * UTC time. |
||
71 | * |
||
72 | * @param string|integer|\DateTime $value Date time value |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | 5 | private function formatDateTime($value) |
|
80 | |||
81 | /** |
||
82 | * Create an HTTP date (RFC 1123 / RFC 822) formatted UTC date-time string |
||
83 | * |
||
84 | * @param string|integer|\DateTime $value Date time value |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | 1 | private function formatDateTimeHttp($value) |
|
92 | |||
93 | /** |
||
94 | * Create a YYYY-MM-DD formatted string |
||
95 | * |
||
96 | * @param string|integer|\DateTime $value Date time value |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | 1 | private function formatDate($value) |
|
104 | |||
105 | /** |
||
106 | * Create a hh:mm:ss formatted string |
||
107 | * |
||
108 | * @param string|integer|\DateTime $value Date time value |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | 2 | private function formatTime($value) |
|
116 | |||
117 | /** |
||
118 | * Formats a boolean value as a string |
||
119 | * |
||
120 | * @param string|integer|bool $value Value to convert to a boolean |
||
121 | * 'true' / 'false' value |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 4 | private function formatBooleanAsString($value) |
|
129 | |||
130 | /** |
||
131 | * Return a UNIX timestamp in the UTC timezone |
||
132 | * |
||
133 | * @param string|integer|\DateTime $value Time value |
||
134 | * |
||
135 | * @return int |
||
136 | */ |
||
137 | 4 | private function formatTimestamp($value) |
|
141 | } |
||
142 |