1 | <?php |
||
30 | final class Utils |
||
31 | { |
||
32 | /** |
||
33 | * Get the content of given file and returns the results. |
||
34 | * |
||
35 | * @param string $file The path to the file |
||
36 | * |
||
37 | * @return string The results of the include |
||
38 | * @since 0.2.4 |
||
39 | * @codeCoverageIgnore |
||
40 | */ |
||
41 | public static function getContent($file = null) |
||
45 | |||
46 | /** |
||
47 | * Takes a value and checks if it's a Closure or not, if it's a Closure it |
||
48 | * will return the result of the closure, if not, it will simply return the |
||
49 | * value. |
||
50 | * |
||
51 | * @param string|null $var The value to get |
||
52 | * |
||
53 | * @return mixed |
||
54 | * @since 0.1.0 |
||
55 | * @codeCoverageIgnore |
||
56 | */ |
||
57 | public static function checkValue($var = null) |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | * |
||
65 | * @param array $array Configuration items |
||
66 | * |
||
67 | * @return array |
||
68 | * |
||
69 | * @since 0.2.4 |
||
70 | * @codeCoverageIgnore |
||
71 | */ |
||
72 | public static function unescapeProperties(array &$array) |
||
80 | |||
81 | /** |
||
82 | * Fix value types of the given array. |
||
83 | * |
||
84 | * @param array $array The Array to fix |
||
85 | * |
||
86 | * @return array |
||
87 | * @since 0.2.4 |
||
88 | * @codeCoverageIgnore |
||
89 | */ |
||
90 | public static function fixArrayValues(array &$array) |
||
116 | |||
117 | /** |
||
118 | * Remove quotes. |
||
119 | * |
||
120 | * @param string $string The string to remove quotes from |
||
121 | * |
||
122 | * @return string |
||
123 | * @since 0.2.4 |
||
124 | * @codeCoverageIgnore |
||
125 | */ |
||
126 | public static function removeQuotes($string = null) |
||
136 | |||
137 | /** |
||
138 | * Trim array elements. |
||
139 | * |
||
140 | * @param array $array Configuration items |
||
141 | * |
||
142 | * @return mixed |
||
143 | * @since 0.2.4 |
||
144 | * @codeCoverageIgnore |
||
145 | */ |
||
146 | public static function trimArrayElements(array &$array) |
||
156 | |||
157 | /** |
||
158 | * Strip Backslashes from given array's elements. |
||
159 | * |
||
160 | * @param array $array Array to work with |
||
161 | * |
||
162 | * @return array |
||
163 | * @since 0.2.4 |
||
164 | * @codeCoverageIgnore |
||
165 | */ |
||
166 | public static function stripBackslashes(array &$array) |
||
174 | |||
175 | // Barrowed from: https://github.com/fvsch/php-trim-whitespace |
||
176 | |||
177 | /** |
||
178 | * Trim whitespace in multiline text |
||
179 | * |
||
180 | * By default, removes leading and trailing whitespace, collapses all other |
||
181 | * space sequences, and removes blank lines. Most of this can be controlled |
||
182 | * by passing an options array with the following keys: |
||
183 | * |
||
184 | * - leading (bool, true): should we trim leading whitespace? |
||
185 | * - inside (bool, true): should we collapse spaces within a line |
||
186 | * (not leading whitespace)? |
||
187 | * - blankLines (int, 0): max number of consecutive blank lines; |
||
188 | * use false to disable. |
||
189 | * - tabWidth (int, 4): number of spaces to use when replacing tabs. |
||
190 | * |
||
191 | * The default settings can be used as basic minification for HTML text |
||
192 | * (except for preformatted text!). This function can be used remove extra |
||
193 | * whitespace generated by a mix of PHP and HTML or by a template engine. |
||
194 | * |
||
195 | * This function forces two behaviors: |
||
196 | * - Trailing whitespace will be removed, always. |
||
197 | * - Tab characters will be replaced by space characters, always |
||
198 | * (for performance reasons). |
||
199 | * |
||
200 | * This was summarily tested on PHP 5.6 and PHP 7 to be as fast as possible, |
||
201 | * and tested against different approches (e.g. splitting as an array and using |
||
202 | * PHP’s trim function). The fastest solution found was using str_replace when |
||
203 | * possible and preg_replace otherwise with very simple regexps to avoid big |
||
204 | * perf costs. The current implementation should be, if not the fastest |
||
205 | * possible, probably close enough. |
||
206 | * |
||
207 | * @param string $string String to trim |
||
208 | * @param array $options Options |
||
209 | * |
||
210 | * @return string |
||
211 | * @since 0.2.5 |
||
212 | * @codeCoverageIgnore |
||
213 | */ |
||
214 | public static function trimWhitespace($string, array $options = []) |
||
303 | |||
304 | /** |
||
305 | * __toString. |
||
306 | * |
||
307 | * @return string |
||
308 | * @since 0.1.2 |
||
309 | * @codeCoverageIgnore |
||
310 | */ |
||
311 | public function __toString() |
||
315 | } |
||
316 | |||
318 |