1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,1265 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-use PhpOption\Option; |
|
4 |
-use Illuminate\Support\Arr; |
|
5 |
-use Illuminate\Support\Str; |
|
6 |
-use Illuminate\Support\Optional; |
|
7 |
-use Illuminate\Support\Collection; |
|
8 |
-use Dotenv\Environment\DotenvFactory; |
|
9 |
-use Illuminate\Contracts\Support\Htmlable; |
|
10 |
-use Illuminate\Support\HigherOrderTapProxy; |
|
11 |
-use Dotenv\Environment\Adapter\PutenvAdapter; |
|
12 |
-use Dotenv\Environment\Adapter\EnvConstAdapter; |
|
13 |
-use Dotenv\Environment\Adapter\ServerConstAdapter; |
|
14 |
- |
|
15 |
-if (! function_exists('append_config')) { |
|
16 |
- /** |
|
17 |
- * Assign high numeric IDs to a config item to force appending. |
|
18 |
- * |
|
19 |
- * @param array $array |
|
20 |
- * @return array |
|
21 |
- */ |
|
22 |
- function append_config(array $array) |
|
23 |
- { |
|
24 |
- $start = 9999; |
|
25 |
- |
|
26 |
- foreach ($array as $key => $value) { |
|
27 |
- if (is_numeric($key)) { |
|
28 |
- $start++; |
|
29 |
- |
|
30 |
- $array[$start] = Arr::pull($array, $key); |
|
31 |
- } |
|
32 |
- } |
|
33 |
- |
|
34 |
- return $array; |
|
35 |
- } |
|
36 |
-} |
|
37 |
- |
|
38 |
-if (! function_exists('array_add')) { |
|
39 |
- /** |
|
40 |
- * Add an element to an array using "dot" notation if it doesn't exist. |
|
41 |
- * |
|
42 |
- * @param array $array |
|
43 |
- * @param string $key |
|
44 |
- * @param mixed $value |
|
45 |
- * @return array |
|
46 |
- * |
|
47 |
- * @deprecated Arr::add() should be used directly instead. Will be removed in Laravel 6.0. |
|
48 |
- */ |
|
49 |
- function array_add($array, $key, $value) |
|
50 |
- { |
|
51 |
- return Arr::add($array, $key, $value); |
|
52 |
- } |
|
53 |
-} |
|
54 |
- |
|
55 |
-if (! function_exists('array_collapse')) { |
|
56 |
- /** |
|
57 |
- * Collapse an array of arrays into a single array. |
|
58 |
- * |
|
59 |
- * @param array $array |
|
60 |
- * @return array |
|
61 |
- * |
|
62 |
- * @deprecated Arr::collapse() should be used directly instead. Will be removed in Laravel 6.0. |
|
63 |
- */ |
|
64 |
- function array_collapse($array) |
|
65 |
- { |
|
66 |
- return Arr::collapse($array); |
|
67 |
- } |
|
68 |
-} |
|
69 |
- |
|
70 |
-if (! function_exists('array_divide')) { |
|
71 |
- /** |
|
72 |
- * Divide an array into two arrays. One with keys and the other with values. |
|
73 |
- * |
|
74 |
- * @param array $array |
|
75 |
- * @return array |
|
76 |
- * |
|
77 |
- * @deprecated Arr::divide() should be used directly instead. Will be removed in Laravel 6.0. |
|
78 |
- */ |
|
79 |
- function array_divide($array) |
|
80 |
- { |
|
81 |
- return Arr::divide($array); |
|
82 |
- } |
|
83 |
-} |
|
84 |
- |
|
85 |
-if (! function_exists('array_dot')) { |
|
86 |
- /** |
|
87 |
- * Flatten a multi-dimensional associative array with dots. |
|
88 |
- * |
|
89 |
- * @param array $array |
|
90 |
- * @param string $prepend |
|
91 |
- * @return array |
|
92 |
- * |
|
93 |
- * @deprecated Arr::dot() should be used directly instead. Will be removed in Laravel 6.0. |
|
94 |
- */ |
|
95 |
- function array_dot($array, $prepend = '') |
|
96 |
- { |
|
97 |
- return Arr::dot($array, $prepend); |
|
98 |
- } |
|
99 |
-} |
|
100 |
- |
|
101 |
-if (! function_exists('array_except')) { |
|
102 |
- /** |
|
103 |
- * Get all of the given array except for a specified array of keys. |
|
104 |
- * |
|
105 |
- * @param array $array |
|
106 |
- * @param array|string $keys |
|
107 |
- * @return array |
|
108 |
- * |
|
109 |
- * @deprecated Arr::except() should be used directly instead. Will be removed in Laravel 6.0. |
|
110 |
- */ |
|
111 |
- function array_except($array, $keys) |
|
112 |
- { |
|
113 |
- return Arr::except($array, $keys); |
|
114 |
- } |
|
115 |
-} |
|
116 |
- |
|
117 |
-if (! function_exists('array_first')) { |
|
118 |
- /** |
|
119 |
- * Return the first element in an array passing a given truth test. |
|
120 |
- * |
|
121 |
- * @param array $array |
|
122 |
- * @param callable|null $callback |
|
123 |
- * @param mixed $default |
|
124 |
- * @return mixed |
|
125 |
- * |
|
126 |
- * @deprecated Arr::first() should be used directly instead. Will be removed in Laravel 6.0. |
|
127 |
- */ |
|
128 |
- function array_first($array, callable $callback = null, $default = null) |
|
129 |
- { |
|
130 |
- return Arr::first($array, $callback, $default); |
|
131 |
- } |
|
132 |
-} |
|
133 |
- |
|
134 |
-if (! function_exists('array_flatten')) { |
|
135 |
- /** |
|
136 |
- * Flatten a multi-dimensional array into a single level. |
|
137 |
- * |
|
138 |
- * @param array $array |
|
139 |
- * @param int $depth |
|
140 |
- * @return array |
|
141 |
- * |
|
142 |
- * @deprecated Arr::flatten() should be used directly instead. Will be removed in Laravel 6.0. |
|
143 |
- */ |
|
144 |
- function array_flatten($array, $depth = INF) |
|
145 |
- { |
|
146 |
- return Arr::flatten($array, $depth); |
|
147 |
- } |
|
148 |
-} |
|
149 |
- |
|
150 |
-if (! function_exists('array_forget')) { |
|
151 |
- /** |
|
152 |
- * Remove one or many array items from a given array using "dot" notation. |
|
153 |
- * |
|
154 |
- * @param array $array |
|
155 |
- * @param array|string $keys |
|
156 |
- * @return void |
|
157 |
- * |
|
158 |
- * @deprecated Arr::forget() should be used directly instead. Will be removed in Laravel 6.0. |
|
159 |
- */ |
|
160 |
- function array_forget(&$array, $keys) |
|
161 |
- { |
|
162 |
- return Arr::forget($array, $keys); |
|
163 |
- } |
|
164 |
-} |
|
165 |
- |
|
166 |
-if (! function_exists('array_get')) { |
|
167 |
- /** |
|
168 |
- * Get an item from an array using "dot" notation. |
|
169 |
- * |
|
170 |
- * @param \ArrayAccess|array $array |
|
171 |
- * @param string $key |
|
172 |
- * @param mixed $default |
|
173 |
- * @return mixed |
|
174 |
- * |
|
175 |
- * @deprecated Arr::get() should be used directly instead. Will be removed in Laravel 6.0. |
|
176 |
- */ |
|
177 |
- function array_get($array, $key, $default = null) |
|
178 |
- { |
|
179 |
- return Arr::get($array, $key, $default); |
|
180 |
- } |
|
181 |
-} |
|
182 |
- |
|
183 |
-if (! function_exists('array_has')) { |
|
184 |
- /** |
|
185 |
- * Check if an item or items exist in an array using "dot" notation. |
|
186 |
- * |
|
187 |
- * @param \ArrayAccess|array $array |
|
188 |
- * @param string|array $keys |
|
189 |
- * @return bool |
|
190 |
- * |
|
191 |
- * @deprecated Arr::has() should be used directly instead. Will be removed in Laravel 6.0. |
|
192 |
- */ |
|
193 |
- function array_has($array, $keys) |
|
194 |
- { |
|
195 |
- return Arr::has($array, $keys); |
|
196 |
- } |
|
197 |
-} |
|
198 |
- |
|
199 |
-if (! function_exists('array_last')) { |
|
200 |
- /** |
|
201 |
- * Return the last element in an array passing a given truth test. |
|
202 |
- * |
|
203 |
- * @param array $array |
|
204 |
- * @param callable|null $callback |
|
205 |
- * @param mixed $default |
|
206 |
- * @return mixed |
|
207 |
- * |
|
208 |
- * @deprecated Arr::last() should be used directly instead. Will be removed in Laravel 6.0. |
|
209 |
- */ |
|
210 |
- function array_last($array, callable $callback = null, $default = null) |
|
211 |
- { |
|
212 |
- return Arr::last($array, $callback, $default); |
|
213 |
- } |
|
214 |
-} |
|
215 |
- |
|
216 |
-if (! function_exists('array_only')) { |
|
217 |
- /** |
|
218 |
- * Get a subset of the items from the given array. |
|
219 |
- * |
|
220 |
- * @param array $array |
|
221 |
- * @param array|string $keys |
|
222 |
- * @return array |
|
223 |
- * |
|
224 |
- * @deprecated Arr::only() should be used directly instead. Will be removed in Laravel 6.0. |
|
225 |
- */ |
|
226 |
- function array_only($array, $keys) |
|
227 |
- { |
|
228 |
- return Arr::only($array, $keys); |
|
229 |
- } |
|
230 |
-} |
|
231 |
- |
|
232 |
-if (! function_exists('array_pluck')) { |
|
233 |
- /** |
|
234 |
- * Pluck an array of values from an array. |
|
235 |
- * |
|
236 |
- * @param array $array |
|
237 |
- * @param string|array $value |
|
238 |
- * @param string|array|null $key |
|
239 |
- * @return array |
|
240 |
- * |
|
241 |
- * @deprecated Arr::pluck() should be used directly instead. Will be removed in Laravel 6.0. |
|
242 |
- */ |
|
243 |
- function array_pluck($array, $value, $key = null) |
|
244 |
- { |
|
245 |
- return Arr::pluck($array, $value, $key); |
|
246 |
- } |
|
247 |
-} |
|
248 |
- |
|
249 |
-if (! function_exists('array_prepend')) { |
|
250 |
- /** |
|
251 |
- * Push an item onto the beginning of an array. |
|
252 |
- * |
|
253 |
- * @param array $array |
|
254 |
- * @param mixed $value |
|
255 |
- * @param mixed $key |
|
256 |
- * @return array |
|
257 |
- * |
|
258 |
- * @deprecated Arr::prepend() should be used directly instead. Will be removed in Laravel 6.0. |
|
259 |
- */ |
|
260 |
- function array_prepend($array, $value, $key = null) |
|
261 |
- { |
|
262 |
- return Arr::prepend($array, $value, $key); |
|
263 |
- } |
|
264 |
-} |
|
265 |
- |
|
266 |
-if (! function_exists('array_pull')) { |
|
267 |
- /** |
|
268 |
- * Get a value from the array, and remove it. |
|
269 |
- * |
|
270 |
- * @param array $array |
|
271 |
- * @param string $key |
|
272 |
- * @param mixed $default |
|
273 |
- * @return mixed |
|
274 |
- * |
|
275 |
- * @deprecated Arr::pull() should be used directly instead. Will be removed in Laravel 6.0. |
|
276 |
- */ |
|
277 |
- function array_pull(&$array, $key, $default = null) |
|
278 |
- { |
|
279 |
- return Arr::pull($array, $key, $default); |
|
280 |
- } |
|
281 |
-} |
|
282 |
- |
|
283 |
-if (! function_exists('array_random')) { |
|
284 |
- /** |
|
285 |
- * Get a random value from an array. |
|
286 |
- * |
|
287 |
- * @param array $array |
|
288 |
- * @param int|null $num |
|
289 |
- * @return mixed |
|
290 |
- * |
|
291 |
- * @deprecated Arr::random() should be used directly instead. Will be removed in Laravel 6.0. |
|
292 |
- */ |
|
293 |
- function array_random($array, $num = null) |
|
294 |
- { |
|
295 |
- return Arr::random($array, $num); |
|
296 |
- } |
|
297 |
-} |
|
298 |
- |
|
299 |
-if (! function_exists('array_set')) { |
|
300 |
- /** |
|
301 |
- * Set an array item to a given value using "dot" notation. |
|
302 |
- * |
|
303 |
- * If no key is given to the method, the entire array will be replaced. |
|
304 |
- * |
|
305 |
- * @param array $array |
|
306 |
- * @param string $key |
|
307 |
- * @param mixed $value |
|
308 |
- * @return array |
|
309 |
- * |
|
310 |
- * @deprecated Arr::set() should be used directly instead. Will be removed in Laravel 6.0. |
|
311 |
- */ |
|
312 |
- function array_set(&$array, $key, $value) |
|
313 |
- { |
|
314 |
- return Arr::set($array, $key, $value); |
|
315 |
- } |
|
316 |
-} |
|
317 |
- |
|
318 |
-if (! function_exists('array_sort')) { |
|
319 |
- /** |
|
320 |
- * Sort the array by the given callback or attribute name. |
|
321 |
- * |
|
322 |
- * @param array $array |
|
323 |
- * @param callable|string|null $callback |
|
324 |
- * @return array |
|
325 |
- * |
|
326 |
- * @deprecated Arr::sort() should be used directly instead. Will be removed in Laravel 6.0. |
|
327 |
- */ |
|
328 |
- function array_sort($array, $callback = null) |
|
329 |
- { |
|
330 |
- return Arr::sort($array, $callback); |
|
331 |
- } |
|
332 |
-} |
|
333 |
- |
|
334 |
-if (! function_exists('array_sort_recursive')) { |
|
335 |
- /** |
|
336 |
- * Recursively sort an array by keys and values. |
|
337 |
- * |
|
338 |
- * @param array $array |
|
339 |
- * @return array |
|
340 |
- * |
|
341 |
- * @deprecated Arr::sortRecursive() should be used directly instead. Will be removed in Laravel 6.0. |
|
342 |
- */ |
|
343 |
- function array_sort_recursive($array) |
|
344 |
- { |
|
345 |
- return Arr::sortRecursive($array); |
|
346 |
- } |
|
347 |
-} |
|
348 |
- |
|
349 |
-if (! function_exists('array_where')) { |
|
350 |
- /** |
|
351 |
- * Filter the array using the given callback. |
|
352 |
- * |
|
353 |
- * @param array $array |
|
354 |
- * @param callable $callback |
|
355 |
- * @return array |
|
356 |
- * |
|
357 |
- * @deprecated Arr::where() should be used directly instead. Will be removed in Laravel 6.0. |
|
358 |
- */ |
|
359 |
- function array_where($array, callable $callback) |
|
360 |
- { |
|
361 |
- return Arr::where($array, $callback); |
|
362 |
- } |
|
363 |
-} |
|
364 |
- |
|
365 |
-if (! function_exists('array_wrap')) { |
|
366 |
- /** |
|
367 |
- * If the given value is not an array, wrap it in one. |
|
368 |
- * |
|
369 |
- * @param mixed $value |
|
370 |
- * @return array |
|
371 |
- * |
|
372 |
- * @deprecated Arr::wrap() should be used directly instead. Will be removed in Laravel 6.0. |
|
373 |
- */ |
|
374 |
- function array_wrap($value) |
|
375 |
- { |
|
376 |
- return Arr::wrap($value); |
|
377 |
- } |
|
378 |
-} |
|
379 |
- |
|
380 |
-if (! function_exists('blank')) { |
|
381 |
- /** |
|
382 |
- * Determine if the given value is "blank". |
|
383 |
- * |
|
384 |
- * @param mixed $value |
|
385 |
- * @return bool |
|
386 |
- */ |
|
387 |
- function blank($value) |
|
388 |
- { |
|
389 |
- if (is_null($value)) { |
|
390 |
- return true; |
|
391 |
- } |
|
392 |
- |
|
393 |
- if (is_string($value)) { |
|
394 |
- return trim($value) === ''; |
|
395 |
- } |
|
396 |
- |
|
397 |
- if (is_numeric($value) || is_bool($value)) { |
|
398 |
- return false; |
|
399 |
- } |
|
400 |
- |
|
401 |
- if ($value instanceof Countable) { |
|
402 |
- return count($value) === 0; |
|
403 |
- } |
|
404 |
- |
|
405 |
- return empty($value); |
|
406 |
- } |
|
407 |
-} |
|
408 |
- |
|
409 |
-if (! function_exists('camel_case')) { |
|
410 |
- /** |
|
411 |
- * Convert a value to camel case. |
|
412 |
- * |
|
413 |
- * @param string $value |
|
414 |
- * @return string |
|
415 |
- * |
|
416 |
- * @deprecated Str::camel() should be used directly instead. Will be removed in Laravel 6.0. |
|
417 |
- */ |
|
418 |
- function camel_case($value) |
|
419 |
- { |
|
420 |
- return Str::camel($value); |
|
421 |
- } |
|
422 |
-} |
|
423 |
- |
|
424 |
-if (! function_exists('class_basename')) { |
|
425 |
- /** |
|
426 |
- * Get the class "basename" of the given object / class. |
|
427 |
- * |
|
428 |
- * @param string|object $class |
|
429 |
- * @return string |
|
430 |
- */ |
|
431 |
- function class_basename($class) |
|
432 |
- { |
|
433 |
- $class = is_object($class) ? get_class($class) : $class; |
|
434 |
- |
|
435 |
- return basename(str_replace('\\', '/', $class)); |
|
436 |
- } |
|
437 |
-} |
|
438 |
- |
|
439 |
-if (! function_exists('class_uses_recursive')) { |
|
440 |
- /** |
|
441 |
- * Returns all traits used by a class, its parent classes and trait of their traits. |
|
442 |
- * |
|
443 |
- * @param object|string $class |
|
444 |
- * @return array |
|
445 |
- */ |
|
446 |
- function class_uses_recursive($class) |
|
447 |
- { |
|
448 |
- if (is_object($class)) { |
|
449 |
- $class = get_class($class); |
|
450 |
- } |
|
451 |
- |
|
452 |
- $results = []; |
|
453 |
- |
|
454 |
- foreach (array_reverse(class_parents($class)) + [$class => $class] as $class) { |
|
455 |
- $results += trait_uses_recursive($class); |
|
456 |
- } |
|
457 |
- |
|
458 |
- return array_unique($results); |
|
459 |
- } |
|
460 |
-} |
|
461 |
- |
|
462 |
-if (! function_exists('collect')) { |
|
463 |
- /** |
|
464 |
- * Create a collection from the given value. |
|
465 |
- * |
|
466 |
- * @param mixed $value |
|
467 |
- * @return \Illuminate\Support\Collection |
|
468 |
- */ |
|
469 |
- function collect($value = null) |
|
470 |
- { |
|
471 |
- return new Collection($value); |
|
472 |
- } |
|
473 |
-} |
|
474 |
- |
|
475 |
-if (! function_exists('data_fill')) { |
|
476 |
- /** |
|
477 |
- * Fill in data where it's missing. |
|
478 |
- * |
|
479 |
- * @param mixed $target |
|
480 |
- * @param string|array $key |
|
481 |
- * @param mixed $value |
|
482 |
- * @return mixed |
|
483 |
- */ |
|
484 |
- function data_fill(&$target, $key, $value) |
|
485 |
- { |
|
486 |
- return data_set($target, $key, $value, false); |
|
487 |
- } |
|
488 |
-} |
|
489 |
- |
|
490 |
-if (! function_exists('data_get')) { |
|
491 |
- /** |
|
492 |
- * Get an item from an array or object using "dot" notation. |
|
493 |
- * |
|
494 |
- * @param mixed $target |
|
495 |
- * @param string|array|int $key |
|
496 |
- * @param mixed $default |
|
497 |
- * @return mixed |
|
498 |
- */ |
|
499 |
- function data_get($target, $key, $default = null) |
|
500 |
- { |
|
501 |
- if (is_null($key)) { |
|
502 |
- return $target; |
|
503 |
- } |
|
504 |
- |
|
505 |
- $key = is_array($key) ? $key : explode('.', $key); |
|
506 |
- |
|
507 |
- while (! is_null($segment = array_shift($key))) { |
|
508 |
- if ($segment === '*') { |
|
509 |
- if ($target instanceof Collection) { |
|
510 |
- $target = $target->all(); |
|
511 |
- } elseif (! is_array($target)) { |
|
512 |
- return value($default); |
|
513 |
- } |
|
514 |
- |
|
515 |
- $result = []; |
|
516 |
- |
|
517 |
- foreach ($target as $item) { |
|
518 |
- $result[] = data_get($item, $key); |
|
519 |
- } |
|
520 |
- |
|
521 |
- return in_array('*', $key) ? Arr::collapse($result) : $result; |
|
522 |
- } |
|
523 |
- |
|
524 |
- if (Arr::accessible($target) && Arr::exists($target, $segment)) { |
|
525 |
- $target = $target[$segment]; |
|
526 |
- } elseif (is_object($target) && isset($target->{$segment})) { |
|
527 |
- $target = $target->{$segment}; |
|
528 |
- } else { |
|
529 |
- return value($default); |
|
530 |
- } |
|
531 |
- } |
|
532 |
- |
|
533 |
- return $target; |
|
534 |
- } |
|
535 |
-} |
|
536 |
- |
|
537 |
-if (! function_exists('data_set')) { |
|
538 |
- /** |
|
539 |
- * Set an item on an array or object using dot notation. |
|
540 |
- * |
|
541 |
- * @param mixed $target |
|
542 |
- * @param string|array $key |
|
543 |
- * @param mixed $value |
|
544 |
- * @param bool $overwrite |
|
545 |
- * @return mixed |
|
546 |
- */ |
|
547 |
- function data_set(&$target, $key, $value, $overwrite = true) |
|
548 |
- { |
|
549 |
- $segments = is_array($key) ? $key : explode('.', $key); |
|
550 |
- |
|
551 |
- if (($segment = array_shift($segments)) === '*') { |
|
552 |
- if (! Arr::accessible($target)) { |
|
553 |
- $target = []; |
|
554 |
- } |
|
555 |
- |
|
556 |
- if ($segments) { |
|
557 |
- foreach ($target as &$inner) { |
|
558 |
- data_set($inner, $segments, $value, $overwrite); |
|
559 |
- } |
|
560 |
- } elseif ($overwrite) { |
|
561 |
- foreach ($target as &$inner) { |
|
562 |
- $inner = $value; |
|
563 |
- } |
|
564 |
- } |
|
565 |
- } elseif (Arr::accessible($target)) { |
|
566 |
- if ($segments) { |
|
567 |
- if (! Arr::exists($target, $segment)) { |
|
568 |
- $target[$segment] = []; |
|
569 |
- } |
|
570 |
- |
|
571 |
- data_set($target[$segment], $segments, $value, $overwrite); |
|
572 |
- } elseif ($overwrite || ! Arr::exists($target, $segment)) { |
|
573 |
- $target[$segment] = $value; |
|
574 |
- } |
|
575 |
- } elseif (is_object($target)) { |
|
576 |
- if ($segments) { |
|
577 |
- if (! isset($target->{$segment})) { |
|
578 |
- $target->{$segment} = []; |
|
579 |
- } |
|
580 |
- |
|
581 |
- data_set($target->{$segment}, $segments, $value, $overwrite); |
|
582 |
- } elseif ($overwrite || ! isset($target->{$segment})) { |
|
583 |
- $target->{$segment} = $value; |
|
584 |
- } |
|
585 |
- } else { |
|
586 |
- $target = []; |
|
587 |
- |
|
588 |
- if ($segments) { |
|
589 |
- data_set($target[$segment], $segments, $value, $overwrite); |
|
590 |
- } elseif ($overwrite) { |
|
591 |
- $target[$segment] = $value; |
|
592 |
- } |
|
593 |
- } |
|
594 |
- |
|
595 |
- return $target; |
|
596 |
- } |
|
597 |
-} |
|
598 |
- |
|
599 |
-if (! function_exists('e')) { |
|
600 |
- /** |
|
601 |
- * Encode HTML special characters in a string. |
|
602 |
- * |
|
603 |
- * @param \Illuminate\Contracts\Support\Htmlable|string $value |
|
604 |
- * @param bool $doubleEncode |
|
605 |
- * @return string |
|
606 |
- */ |
|
607 |
- function e($value, $doubleEncode = true) |
|
608 |
- { |
|
609 |
- if ($value instanceof Htmlable) { |
|
610 |
- return $value->toHtml(); |
|
611 |
- } |
|
612 |
- |
|
613 |
- return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', $doubleEncode); |
|
614 |
- } |
|
615 |
-} |
|
616 |
- |
|
617 |
-if (! function_exists('ends_with')) { |
|
618 |
- /** |
|
619 |
- * Determine if a given string ends with a given substring. |
|
620 |
- * |
|
621 |
- * @param string $haystack |
|
622 |
- * @param string|array $needles |
|
623 |
- * @return bool |
|
624 |
- * |
|
625 |
- * @deprecated Str::endsWith() should be used directly instead. Will be removed in Laravel 6.0. |
|
626 |
- */ |
|
627 |
- function ends_with($haystack, $needles) |
|
628 |
- { |
|
629 |
- return Str::endsWith($haystack, $needles); |
|
630 |
- } |
|
631 |
-} |
|
632 |
- |
|
633 |
-if (! function_exists('env')) { |
|
634 |
- /** |
|
635 |
- * Gets the value of an environment variable. |
|
636 |
- * |
|
637 |
- * @param string $key |
|
638 |
- * @param mixed $default |
|
639 |
- * @return mixed |
|
640 |
- */ |
|
641 |
- function env($key, $default = null) |
|
642 |
- { |
|
643 |
- static $variables; |
|
644 |
- |
|
645 |
- if ($variables === null) { |
|
646 |
- $variables = (new DotenvFactory([new EnvConstAdapter, new PutenvAdapter, new ServerConstAdapter]))->createImmutable(); |
|
647 |
- } |
|
648 |
- |
|
649 |
- return Option::fromValue($variables->get($key)) |
|
650 |
- ->map(function ($value) { |
|
651 |
- switch (strtolower($value)) { |
|
652 |
- case 'true': |
|
653 |
- case '(true)': |
|
654 |
- return true; |
|
655 |
- case 'false': |
|
656 |
- case '(false)': |
|
657 |
- return false; |
|
658 |
- case 'empty': |
|
659 |
- case '(empty)': |
|
660 |
- return ''; |
|
661 |
- case 'null': |
|
662 |
- case '(null)': |
|
663 |
- return; |
|
664 |
- } |
|
665 |
- |
|
666 |
- if (preg_match('/\A([\'"])(.*)\1\z/', $value, $matches)) { |
|
667 |
- return $matches[2]; |
|
668 |
- } |
|
669 |
- |
|
670 |
- return $value; |
|
671 |
- }) |
|
672 |
- ->getOrCall(function () use ($default) { |
|
673 |
- return value($default); |
|
674 |
- }); |
|
675 |
- } |
|
676 |
-} |
|
677 |
- |
|
678 |
-if (! function_exists('filled')) { |
|
679 |
- /** |
|
680 |
- * Determine if a value is "filled". |
|
681 |
- * |
|
682 |
- * @param mixed $value |
|
683 |
- * @return bool |
|
684 |
- */ |
|
685 |
- function filled($value) |
|
686 |
- { |
|
687 |
- return ! blank($value); |
|
688 |
- } |
|
689 |
-} |
|
690 |
- |
|
691 |
-if (! function_exists('head')) { |
|
692 |
- /** |
|
693 |
- * Get the first element of an array. Useful for method chaining. |
|
694 |
- * |
|
695 |
- * @param array $array |
|
696 |
- * @return mixed |
|
697 |
- */ |
|
698 |
- function head($array) |
|
699 |
- { |
|
700 |
- return reset($array); |
|
701 |
- } |
|
702 |
-} |
|
703 |
- |
|
704 |
-if (! function_exists('kebab_case')) { |
|
705 |
- /** |
|
706 |
- * Convert a string to kebab case. |
|
707 |
- * |
|
708 |
- * @param string $value |
|
709 |
- * @return string |
|
710 |
- * |
|
711 |
- * @deprecated Str::kebab() should be used directly instead. Will be removed in Laravel 6.0. |
|
712 |
- */ |
|
713 |
- function kebab_case($value) |
|
714 |
- { |
|
715 |
- return Str::kebab($value); |
|
716 |
- } |
|
717 |
-} |
|
718 |
- |
|
719 |
-if (! function_exists('last')) { |
|
720 |
- /** |
|
721 |
- * Get the last element from an array. |
|
722 |
- * |
|
723 |
- * @param array $array |
|
724 |
- * @return mixed |
|
725 |
- */ |
|
726 |
- function last($array) |
|
727 |
- { |
|
728 |
- return end($array); |
|
729 |
- } |
|
730 |
-} |
|
731 |
- |
|
732 |
-if (! function_exists('object_get')) { |
|
733 |
- /** |
|
734 |
- * Get an item from an object using "dot" notation. |
|
735 |
- * |
|
736 |
- * @param object $object |
|
737 |
- * @param string $key |
|
738 |
- * @param mixed $default |
|
739 |
- * @return mixed |
|
740 |
- */ |
|
741 |
- function object_get($object, $key, $default = null) |
|
742 |
- { |
|
743 |
- if (is_null($key) || trim($key) == '') { |
|
744 |
- return $object; |
|
745 |
- } |
|
746 |
- |
|
747 |
- foreach (explode('.', $key) as $segment) { |
|
748 |
- if (! is_object($object) || ! isset($object->{$segment})) { |
|
749 |
- return value($default); |
|
750 |
- } |
|
751 |
- |
|
752 |
- $object = $object->{$segment}; |
|
753 |
- } |
|
754 |
- |
|
755 |
- return $object; |
|
756 |
- } |
|
757 |
-} |
|
758 |
- |
|
759 |
-if (! function_exists('optional')) { |
|
760 |
- /** |
|
761 |
- * Provide access to optional objects. |
|
762 |
- * |
|
763 |
- * @param mixed $value |
|
764 |
- * @param callable|null $callback |
|
765 |
- * @return mixed |
|
766 |
- */ |
|
767 |
- function optional($value = null, callable $callback = null) |
|
768 |
- { |
|
769 |
- if (is_null($callback)) { |
|
770 |
- return new Optional($value); |
|
771 |
- } elseif (! is_null($value)) { |
|
772 |
- return $callback($value); |
|
773 |
- } |
|
774 |
- } |
|
775 |
-} |
|
776 |
- |
|
777 |
-if (! function_exists('preg_replace_array')) { |
|
778 |
- /** |
|
779 |
- * Replace a given pattern with each value in the array in sequentially. |
|
780 |
- * |
|
781 |
- * @param string $pattern |
|
782 |
- * @param array $replacements |
|
783 |
- * @param string $subject |
|
784 |
- * @return string |
|
785 |
- */ |
|
786 |
- function preg_replace_array($pattern, array $replacements, $subject) |
|
787 |
- { |
|
788 |
- return preg_replace_callback($pattern, function () use (&$replacements) { |
|
789 |
- foreach ($replacements as $key => $value) { |
|
790 |
- return array_shift($replacements); |
|
791 |
- } |
|
792 |
- }, $subject); |
|
793 |
- } |
|
794 |
-} |
|
795 |
- |
|
796 |
-if (! function_exists('retry')) { |
|
797 |
- /** |
|
798 |
- * Retry an operation a given number of times. |
|
799 |
- * |
|
800 |
- * @param int $times |
|
801 |
- * @param callable $callback |
|
802 |
- * @param int $sleep |
|
803 |
- * @param callable $when |
|
804 |
- * @return mixed |
|
805 |
- * |
|
806 |
- * @throws \Exception |
|
807 |
- */ |
|
808 |
- function retry($times, callable $callback, $sleep = 0, $when = null) |
|
809 |
- { |
|
810 |
- $attempts = 0; |
|
811 |
- $times--; |
|
812 |
- |
|
813 |
- beginning: |
|
814 |
- $attempts++; |
|
815 |
- |
|
816 |
- try { |
|
817 |
- return $callback($attempts); |
|
818 |
- } catch (Exception $e) { |
|
819 |
- if (! $times || ($when && ! $when($e))) { |
|
820 |
- throw $e; |
|
821 |
- } |
|
822 |
- |
|
823 |
- $times--; |
|
824 |
- |
|
825 |
- if ($sleep) { |
|
826 |
- usleep($sleep * 1000); |
|
827 |
- } |
|
828 |
- |
|
829 |
- goto beginning; |
|
830 |
- } |
|
831 |
- } |
|
832 |
-} |
|
833 |
- |
|
834 |
-if (! function_exists('snake_case')) { |
|
835 |
- /** |
|
836 |
- * Convert a string to snake case. |
|
837 |
- * |
|
838 |
- * @param string $value |
|
839 |
- * @param string $delimiter |
|
840 |
- * @return string |
|
841 |
- * |
|
842 |
- * @deprecated Str::snake() should be used directly instead. Will be removed in Laravel 6.0. |
|
843 |
- */ |
|
844 |
- function snake_case($value, $delimiter = '_') |
|
845 |
- { |
|
846 |
- return Str::snake($value, $delimiter); |
|
847 |
- } |
|
848 |
-} |
|
849 |
- |
|
850 |
-if (! function_exists('starts_with')) { |
|
851 |
- /** |
|
852 |
- * Determine if a given string starts with a given substring. |
|
853 |
- * |
|
854 |
- * @param string $haystack |
|
855 |
- * @param string|array $needles |
|
856 |
- * @return bool |
|
857 |
- * |
|
858 |
- * @deprecated Str::startsWith() should be used directly instead. Will be removed in Laravel 6.0. |
|
859 |
- */ |
|
860 |
- function starts_with($haystack, $needles) |
|
861 |
- { |
|
862 |
- return Str::startsWith($haystack, $needles); |
|
863 |
- } |
|
864 |
-} |
|
865 |
- |
|
866 |
-if (! function_exists('str_after')) { |
|
867 |
- /** |
|
868 |
- * Return the remainder of a string after a given value. |
|
869 |
- * |
|
870 |
- * @param string $subject |
|
871 |
- * @param string $search |
|
872 |
- * @return string |
|
873 |
- * |
|
874 |
- * @deprecated Str::after() should be used directly instead. Will be removed in Laravel 6.0. |
|
875 |
- */ |
|
876 |
- function str_after($subject, $search) |
|
877 |
- { |
|
878 |
- return Str::after($subject, $search); |
|
879 |
- } |
|
880 |
-} |
|
881 |
- |
|
882 |
-if (! function_exists('str_before')) { |
|
883 |
- /** |
|
884 |
- * Get the portion of a string before a given value. |
|
885 |
- * |
|
886 |
- * @param string $subject |
|
887 |
- * @param string $search |
|
888 |
- * @return string |
|
889 |
- * |
|
890 |
- * @deprecated Str::before() should be used directly instead. Will be removed in Laravel 6.0. |
|
891 |
- */ |
|
892 |
- function str_before($subject, $search) |
|
893 |
- { |
|
894 |
- return Str::before($subject, $search); |
|
895 |
- } |
|
896 |
-} |
|
897 |
- |
|
898 |
-if (! function_exists('str_contains')) { |
|
899 |
- /** |
|
900 |
- * Determine if a given string contains a given substring. |
|
901 |
- * |
|
902 |
- * @param string $haystack |
|
903 |
- * @param string|array $needles |
|
904 |
- * @return bool |
|
905 |
- * |
|
906 |
- * @deprecated Str::contains() should be used directly instead. Will be removed in Laravel 6.0. |
|
907 |
- */ |
|
908 |
- function str_contains($haystack, $needles) |
|
909 |
- { |
|
910 |
- return Str::contains($haystack, $needles); |
|
911 |
- } |
|
912 |
-} |
|
913 |
- |
|
914 |
-if (! function_exists('str_finish')) { |
|
915 |
- /** |
|
916 |
- * Cap a string with a single instance of a given value. |
|
917 |
- * |
|
918 |
- * @param string $value |
|
919 |
- * @param string $cap |
|
920 |
- * @return string |
|
921 |
- * |
|
922 |
- * @deprecated Str::finish() should be used directly instead. Will be removed in Laravel 6.0. |
|
923 |
- */ |
|
924 |
- function str_finish($value, $cap) |
|
925 |
- { |
|
926 |
- return Str::finish($value, $cap); |
|
927 |
- } |
|
928 |
-} |
|
929 |
- |
|
930 |
-if (! function_exists('str_is')) { |
|
931 |
- /** |
|
932 |
- * Determine if a given string matches a given pattern. |
|
933 |
- * |
|
934 |
- * @param string|array $pattern |
|
935 |
- * @param string $value |
|
936 |
- * @return bool |
|
937 |
- * |
|
938 |
- * @deprecated Str::is() should be used directly instead. Will be removed in Laravel 6.0. |
|
939 |
- */ |
|
940 |
- function str_is($pattern, $value) |
|
941 |
- { |
|
942 |
- return Str::is($pattern, $value); |
|
943 |
- } |
|
944 |
-} |
|
945 |
- |
|
946 |
-if (! function_exists('str_limit')) { |
|
947 |
- /** |
|
948 |
- * Limit the number of characters in a string. |
|
949 |
- * |
|
950 |
- * @param string $value |
|
951 |
- * @param int $limit |
|
952 |
- * @param string $end |
|
953 |
- * @return string |
|
954 |
- * |
|
955 |
- * @deprecated Str::limit() should be used directly instead. Will be removed in Laravel 6.0. |
|
956 |
- */ |
|
957 |
- function str_limit($value, $limit = 100, $end = '...') |
|
958 |
- { |
|
959 |
- return Str::limit($value, $limit, $end); |
|
960 |
- } |
|
961 |
-} |
|
962 |
- |
|
963 |
-if (! function_exists('str_plural')) { |
|
964 |
- /** |
|
965 |
- * Get the plural form of an English word. |
|
966 |
- * |
|
967 |
- * @param string $value |
|
968 |
- * @param int $count |
|
969 |
- * @return string |
|
970 |
- * |
|
971 |
- * @deprecated Str::plural() should be used directly instead. Will be removed in Laravel 6.0. |
|
972 |
- */ |
|
973 |
- function str_plural($value, $count = 2) |
|
974 |
- { |
|
975 |
- return Str::plural($value, $count); |
|
976 |
- } |
|
977 |
-} |
|
978 |
- |
|
979 |
-if (! function_exists('str_random')) { |
|
980 |
- /** |
|
981 |
- * Generate a more truly "random" alpha-numeric string. |
|
982 |
- * |
|
983 |
- * @param int $length |
|
984 |
- * @return string |
|
985 |
- * |
|
986 |
- * @throws \RuntimeException |
|
987 |
- * |
|
988 |
- * @deprecated Str::random() should be used directly instead. Will be removed in Laravel 6.0. |
|
989 |
- */ |
|
990 |
- function str_random($length = 16) |
|
991 |
- { |
|
992 |
- return Str::random($length); |
|
993 |
- } |
|
994 |
-} |
|
995 |
- |
|
996 |
-if (! function_exists('str_replace_array')) { |
|
997 |
- /** |
|
998 |
- * Replace a given value in the string sequentially with an array. |
|
999 |
- * |
|
1000 |
- * @param string $search |
|
1001 |
- * @param array $replace |
|
1002 |
- * @param string $subject |
|
1003 |
- * @return string |
|
1004 |
- * |
|
1005 |
- * @deprecated Str::replaceArray() should be used directly instead. Will be removed in Laravel 6.0. |
|
1006 |
- */ |
|
1007 |
- function str_replace_array($search, array $replace, $subject) |
|
1008 |
- { |
|
1009 |
- return Str::replaceArray($search, $replace, $subject); |
|
1010 |
- } |
|
1011 |
-} |
|
1012 |
- |
|
1013 |
-if (! function_exists('str_replace_first')) { |
|
1014 |
- /** |
|
1015 |
- * Replace the first occurrence of a given value in the string. |
|
1016 |
- * |
|
1017 |
- * @param string $search |
|
1018 |
- * @param string $replace |
|
1019 |
- * @param string $subject |
|
1020 |
- * @return string |
|
1021 |
- * |
|
1022 |
- * @deprecated Str::replaceFirst() should be used directly instead. Will be removed in Laravel 6.0. |
|
1023 |
- */ |
|
1024 |
- function str_replace_first($search, $replace, $subject) |
|
1025 |
- { |
|
1026 |
- return Str::replaceFirst($search, $replace, $subject); |
|
1027 |
- } |
|
1028 |
-} |
|
1029 |
- |
|
1030 |
-if (! function_exists('str_replace_last')) { |
|
1031 |
- /** |
|
1032 |
- * Replace the last occurrence of a given value in the string. |
|
1033 |
- * |
|
1034 |
- * @param string $search |
|
1035 |
- * @param string $replace |
|
1036 |
- * @param string $subject |
|
1037 |
- * @return string |
|
1038 |
- * |
|
1039 |
- * @deprecated Str::replaceLast() should be used directly instead. Will be removed in Laravel 6.0. |
|
1040 |
- */ |
|
1041 |
- function str_replace_last($search, $replace, $subject) |
|
1042 |
- { |
|
1043 |
- return Str::replaceLast($search, $replace, $subject); |
|
1044 |
- } |
|
1045 |
-} |
|
1046 |
- |
|
1047 |
-if (! function_exists('str_singular')) { |
|
1048 |
- /** |
|
1049 |
- * Get the singular form of an English word. |
|
1050 |
- * |
|
1051 |
- * @param string $value |
|
1052 |
- * @return string |
|
1053 |
- * |
|
1054 |
- * @deprecated Str::singular() should be used directly instead. Will be removed in Laravel 6.0. |
|
1055 |
- */ |
|
1056 |
- function str_singular($value) |
|
1057 |
- { |
|
1058 |
- return Str::singular($value); |
|
1059 |
- } |
|
1060 |
-} |
|
1061 |
- |
|
1062 |
-if (! function_exists('str_slug')) { |
|
1063 |
- /** |
|
1064 |
- * Generate a URL friendly "slug" from a given string. |
|
1065 |
- * |
|
1066 |
- * @param string $title |
|
1067 |
- * @param string $separator |
|
1068 |
- * @param string $language |
|
1069 |
- * @return string |
|
1070 |
- * |
|
1071 |
- * @deprecated Str::slug() should be used directly instead. Will be removed in Laravel 6.0. |
|
1072 |
- */ |
|
1073 |
- function str_slug($title, $separator = '-', $language = 'en') |
|
1074 |
- { |
|
1075 |
- return Str::slug($title, $separator, $language); |
|
1076 |
- } |
|
1077 |
-} |
|
1078 |
- |
|
1079 |
-if (! function_exists('str_start')) { |
|
1080 |
- /** |
|
1081 |
- * Begin a string with a single instance of a given value. |
|
1082 |
- * |
|
1083 |
- * @param string $value |
|
1084 |
- * @param string $prefix |
|
1085 |
- * @return string |
|
1086 |
- * |
|
1087 |
- * @deprecated Str::start() should be used directly instead. Will be removed in Laravel 6.0. |
|
1088 |
- */ |
|
1089 |
- function str_start($value, $prefix) |
|
1090 |
- { |
|
1091 |
- return Str::start($value, $prefix); |
|
1092 |
- } |
|
1093 |
-} |
|
1094 |
- |
|
1095 |
-if (! function_exists('studly_case')) { |
|
1096 |
- /** |
|
1097 |
- * Convert a value to studly caps case. |
|
1098 |
- * |
|
1099 |
- * @param string $value |
|
1100 |
- * @return string |
|
1101 |
- * |
|
1102 |
- * @deprecated Str::studly() should be used directly instead. Will be removed in Laravel 6.0. |
|
1103 |
- */ |
|
1104 |
- function studly_case($value) |
|
1105 |
- { |
|
1106 |
- return Str::studly($value); |
|
1107 |
- } |
|
1108 |
-} |
|
1109 |
- |
|
1110 |
-if (! function_exists('tap')) { |
|
1111 |
- /** |
|
1112 |
- * Call the given Closure with the given value then return the value. |
|
1113 |
- * |
|
1114 |
- * @param mixed $value |
|
1115 |
- * @param callable|null $callback |
|
1116 |
- * @return mixed |
|
1117 |
- */ |
|
1118 |
- function tap($value, $callback = null) |
|
1119 |
- { |
|
1120 |
- if (is_null($callback)) { |
|
1121 |
- return new HigherOrderTapProxy($value); |
|
1122 |
- } |
|
1123 |
- |
|
1124 |
- $callback($value); |
|
1125 |
- |
|
1126 |
- return $value; |
|
1127 |
- } |
|
1128 |
-} |
|
1129 |
- |
|
1130 |
-if (! function_exists('throw_if')) { |
|
1131 |
- /** |
|
1132 |
- * Throw the given exception if the given condition is true. |
|
1133 |
- * |
|
1134 |
- * @param mixed $condition |
|
1135 |
- * @param \Throwable|string $exception |
|
1136 |
- * @param array ...$parameters |
|
1137 |
- * @return mixed |
|
1138 |
- * |
|
1139 |
- * @throws \Throwable |
|
1140 |
- */ |
|
1141 |
- function throw_if($condition, $exception, ...$parameters) |
|
1142 |
- { |
|
1143 |
- if ($condition) { |
|
1144 |
- throw (is_string($exception) ? new $exception(...$parameters) : $exception); |
|
1145 |
- } |
|
1146 |
- |
|
1147 |
- return $condition; |
|
1148 |
- } |
|
1149 |
-} |
|
1150 |
- |
|
1151 |
-if (! function_exists('throw_unless')) { |
|
1152 |
- /** |
|
1153 |
- * Throw the given exception unless the given condition is true. |
|
1154 |
- * |
|
1155 |
- * @param mixed $condition |
|
1156 |
- * @param \Throwable|string $exception |
|
1157 |
- * @param array ...$parameters |
|
1158 |
- * @return mixed |
|
1159 |
- * @throws \Throwable |
|
1160 |
- */ |
|
1161 |
- function throw_unless($condition, $exception, ...$parameters) |
|
1162 |
- { |
|
1163 |
- if (! $condition) { |
|
1164 |
- throw (is_string($exception) ? new $exception(...$parameters) : $exception); |
|
1165 |
- } |
|
1166 |
- |
|
1167 |
- return $condition; |
|
1168 |
- } |
|
1169 |
-} |
|
1170 |
- |
|
1171 |
-if (! function_exists('title_case')) { |
|
1172 |
- /** |
|
1173 |
- * Convert a value to title case. |
|
1174 |
- * |
|
1175 |
- * @param string $value |
|
1176 |
- * @return string |
|
1177 |
- * |
|
1178 |
- * @deprecated Str::title() should be used directly instead. Will be removed in Laravel 6.0. |
|
1179 |
- */ |
|
1180 |
- function title_case($value) |
|
1181 |
- { |
|
1182 |
- return Str::title($value); |
|
1183 |
- } |
|
1184 |
-} |
|
1185 |
- |
|
1186 |
-if (! function_exists('trait_uses_recursive')) { |
|
1187 |
- /** |
|
1188 |
- * Returns all traits used by a trait and its traits. |
|
1189 |
- * |
|
1190 |
- * @param string $trait |
|
1191 |
- * @return array |
|
1192 |
- */ |
|
1193 |
- function trait_uses_recursive($trait) |
|
1194 |
- { |
|
1195 |
- $traits = class_uses($trait); |
|
1196 |
- |
|
1197 |
- foreach ($traits as $trait) { |
|
1198 |
- $traits += trait_uses_recursive($trait); |
|
1199 |
- } |
|
1200 |
- |
|
1201 |
- return $traits; |
|
1202 |
- } |
|
1203 |
-} |
|
1204 |
- |
|
1205 |
-if (! function_exists('transform')) { |
|
1206 |
- /** |
|
1207 |
- * Transform the given value if it is present. |
|
1208 |
- * |
|
1209 |
- * @param mixed $value |
|
1210 |
- * @param callable $callback |
|
1211 |
- * @param mixed $default |
|
1212 |
- * @return mixed|null |
|
1213 |
- */ |
|
1214 |
- function transform($value, callable $callback, $default = null) |
|
1215 |
- { |
|
1216 |
- if (filled($value)) { |
|
1217 |
- return $callback($value); |
|
1218 |
- } |
|
1219 |
- |
|
1220 |
- if (is_callable($default)) { |
|
1221 |
- return $default($value); |
|
1222 |
- } |
|
1223 |
- |
|
1224 |
- return $default; |
|
1225 |
- } |
|
1226 |
-} |
|
1227 |
- |
|
1228 |
-if (! function_exists('value')) { |
|
1229 |
- /** |
|
1230 |
- * Return the default value of the given value. |
|
1231 |
- * |
|
1232 |
- * @param mixed $value |
|
1233 |
- * @return mixed |
|
1234 |
- */ |
|
1235 |
- function value($value) |
|
1236 |
- { |
|
1237 |
- return $value instanceof Closure ? $value() : $value; |
|
1238 |
- } |
|
1239 |
-} |
|
1240 |
- |
|
1241 |
-if (! function_exists('windows_os')) { |
|
1242 |
- /** |
|
1243 |
- * Determine whether the current environment is Windows based. |
|
1244 |
- * |
|
1245 |
- * @return bool |
|
1246 |
- */ |
|
1247 |
- function windows_os() |
|
1248 |
- { |
|
1249 |
- return strtolower(substr(PHP_OS, 0, 3)) === 'win'; |
|
1250 |
- } |
|
1251 |
-} |
|
1252 |
- |
|
1253 |
-if (! function_exists('with')) { |
|
1254 |
- /** |
|
1255 |
- * Return the given value, optionally passed through the given callback. |
|
1256 |
- * |
|
1257 |
- * @param mixed $value |
|
1258 |
- * @param callable|null $callback |
|
1259 |
- * @return mixed |
|
1260 |
- */ |
|
1261 |
- function with($value, callable $callback = null) |
|
1262 |
- { |
|
1263 |
- return is_null($callback) ? $value : $callback($value); |
|
1264 |
- } |
|
1265 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,1265 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+use PhpOption\Option; |
|
4 |
+use Illuminate\Support\Arr; |
|
5 |
+use Illuminate\Support\Str; |
|
6 |
+use Illuminate\Support\Optional; |
|
7 |
+use Illuminate\Support\Collection; |
|
8 |
+use Dotenv\Environment\DotenvFactory; |
|
9 |
+use Illuminate\Contracts\Support\Htmlable; |
|
10 |
+use Illuminate\Support\HigherOrderTapProxy; |
|
11 |
+use Dotenv\Environment\Adapter\PutenvAdapter; |
|
12 |
+use Dotenv\Environment\Adapter\EnvConstAdapter; |
|
13 |
+use Dotenv\Environment\Adapter\ServerConstAdapter; |
|
14 |
+ |
|
15 |
+if (! function_exists('append_config')) { |
|
16 |
+ /** |
|
17 |
+ * Assign high numeric IDs to a config item to force appending. |
|
18 |
+ * |
|
19 |
+ * @param array $array |
|
20 |
+ * @return array |
|
21 |
+ */ |
|
22 |
+ function append_config(array $array) |
|
23 |
+ { |
|
24 |
+ $start = 9999; |
|
25 |
+ |
|
26 |
+ foreach ($array as $key => $value) { |
|
27 |
+ if (is_numeric($key)) { |
|
28 |
+ $start++; |
|
29 |
+ |
|
30 |
+ $array[$start] = Arr::pull($array, $key); |
|
31 |
+ } |
|
32 |
+ } |
|
33 |
+ |
|
34 |
+ return $array; |
|
35 |
+ } |
|
36 |
+} |
|
37 |
+ |
|
38 |
+if (! function_exists('array_add')) { |
|
39 |
+ /** |
|
40 |
+ * Add an element to an array using "dot" notation if it doesn't exist. |
|
41 |
+ * |
|
42 |
+ * @param array $array |
|
43 |
+ * @param string $key |
|
44 |
+ * @param mixed $value |
|
45 |
+ * @return array |
|
46 |
+ * |
|
47 |
+ * @deprecated Arr::add() should be used directly instead. Will be removed in Laravel 6.0. |
|
48 |
+ */ |
|
49 |
+ function array_add($array, $key, $value) |
|
50 |
+ { |
|
51 |
+ return Arr::add($array, $key, $value); |
|
52 |
+ } |
|
53 |
+} |
|
54 |
+ |
|
55 |
+if (! function_exists('array_collapse')) { |
|
56 |
+ /** |
|
57 |
+ * Collapse an array of arrays into a single array. |
|
58 |
+ * |
|
59 |
+ * @param array $array |
|
60 |
+ * @return array |
|
61 |
+ * |
|
62 |
+ * @deprecated Arr::collapse() should be used directly instead. Will be removed in Laravel 6.0. |
|
63 |
+ */ |
|
64 |
+ function array_collapse($array) |
|
65 |
+ { |
|
66 |
+ return Arr::collapse($array); |
|
67 |
+ } |
|
68 |
+} |
|
69 |
+ |
|
70 |
+if (! function_exists('array_divide')) { |
|
71 |
+ /** |
|
72 |
+ * Divide an array into two arrays. One with keys and the other with values. |
|
73 |
+ * |
|
74 |
+ * @param array $array |
|
75 |
+ * @return array |
|
76 |
+ * |
|
77 |
+ * @deprecated Arr::divide() should be used directly instead. Will be removed in Laravel 6.0. |
|
78 |
+ */ |
|
79 |
+ function array_divide($array) |
|
80 |
+ { |
|
81 |
+ return Arr::divide($array); |
|
82 |
+ } |
|
83 |
+} |
|
84 |
+ |
|
85 |
+if (! function_exists('array_dot')) { |
|
86 |
+ /** |
|
87 |
+ * Flatten a multi-dimensional associative array with dots. |
|
88 |
+ * |
|
89 |
+ * @param array $array |
|
90 |
+ * @param string $prepend |
|
91 |
+ * @return array |
|
92 |
+ * |
|
93 |
+ * @deprecated Arr::dot() should be used directly instead. Will be removed in Laravel 6.0. |
|
94 |
+ */ |
|
95 |
+ function array_dot($array, $prepend = '') |
|
96 |
+ { |
|
97 |
+ return Arr::dot($array, $prepend); |
|
98 |
+ } |
|
99 |
+} |
|
100 |
+ |
|
101 |
+if (! function_exists('array_except')) { |
|
102 |
+ /** |
|
103 |
+ * Get all of the given array except for a specified array of keys. |
|
104 |
+ * |
|
105 |
+ * @param array $array |
|
106 |
+ * @param array|string $keys |
|
107 |
+ * @return array |
|
108 |
+ * |
|
109 |
+ * @deprecated Arr::except() should be used directly instead. Will be removed in Laravel 6.0. |
|
110 |
+ */ |
|
111 |
+ function array_except($array, $keys) |
|
112 |
+ { |
|
113 |
+ return Arr::except($array, $keys); |
|
114 |
+ } |
|
115 |
+} |
|
116 |
+ |
|
117 |
+if (! function_exists('array_first')) { |
|
118 |
+ /** |
|
119 |
+ * Return the first element in an array passing a given truth test. |
|
120 |
+ * |
|
121 |
+ * @param array $array |
|
122 |
+ * @param callable|null $callback |
|
123 |
+ * @param mixed $default |
|
124 |
+ * @return mixed |
|
125 |
+ * |
|
126 |
+ * @deprecated Arr::first() should be used directly instead. Will be removed in Laravel 6.0. |
|
127 |
+ */ |
|
128 |
+ function array_first($array, callable $callback = null, $default = null) |
|
129 |
+ { |
|
130 |
+ return Arr::first($array, $callback, $default); |
|
131 |
+ } |
|
132 |
+} |
|
133 |
+ |
|
134 |
+if (! function_exists('array_flatten')) { |
|
135 |
+ /** |
|
136 |
+ * Flatten a multi-dimensional array into a single level. |
|
137 |
+ * |
|
138 |
+ * @param array $array |
|
139 |
+ * @param int $depth |
|
140 |
+ * @return array |
|
141 |
+ * |
|
142 |
+ * @deprecated Arr::flatten() should be used directly instead. Will be removed in Laravel 6.0. |
|
143 |
+ */ |
|
144 |
+ function array_flatten($array, $depth = INF) |
|
145 |
+ { |
|
146 |
+ return Arr::flatten($array, $depth); |
|
147 |
+ } |
|
148 |
+} |
|
149 |
+ |
|
150 |
+if (! function_exists('array_forget')) { |
|
151 |
+ /** |
|
152 |
+ * Remove one or many array items from a given array using "dot" notation. |
|
153 |
+ * |
|
154 |
+ * @param array $array |
|
155 |
+ * @param array|string $keys |
|
156 |
+ * @return void |
|
157 |
+ * |
|
158 |
+ * @deprecated Arr::forget() should be used directly instead. Will be removed in Laravel 6.0. |
|
159 |
+ */ |
|
160 |
+ function array_forget(&$array, $keys) |
|
161 |
+ { |
|
162 |
+ return Arr::forget($array, $keys); |
|
163 |
+ } |
|
164 |
+} |
|
165 |
+ |
|
166 |
+if (! function_exists('array_get')) { |
|
167 |
+ /** |
|
168 |
+ * Get an item from an array using "dot" notation. |
|
169 |
+ * |
|
170 |
+ * @param \ArrayAccess|array $array |
|
171 |
+ * @param string $key |
|
172 |
+ * @param mixed $default |
|
173 |
+ * @return mixed |
|
174 |
+ * |
|
175 |
+ * @deprecated Arr::get() should be used directly instead. Will be removed in Laravel 6.0. |
|
176 |
+ */ |
|
177 |
+ function array_get($array, $key, $default = null) |
|
178 |
+ { |
|
179 |
+ return Arr::get($array, $key, $default); |
|
180 |
+ } |
|
181 |
+} |
|
182 |
+ |
|
183 |
+if (! function_exists('array_has')) { |
|
184 |
+ /** |
|
185 |
+ * Check if an item or items exist in an array using "dot" notation. |
|
186 |
+ * |
|
187 |
+ * @param \ArrayAccess|array $array |
|
188 |
+ * @param string|array $keys |
|
189 |
+ * @return bool |
|
190 |
+ * |
|
191 |
+ * @deprecated Arr::has() should be used directly instead. Will be removed in Laravel 6.0. |
|
192 |
+ */ |
|
193 |
+ function array_has($array, $keys) |
|
194 |
+ { |
|
195 |
+ return Arr::has($array, $keys); |
|
196 |
+ } |
|
197 |
+} |
|
198 |
+ |
|
199 |
+if (! function_exists('array_last')) { |
|
200 |
+ /** |
|
201 |
+ * Return the last element in an array passing a given truth test. |
|
202 |
+ * |
|
203 |
+ * @param array $array |
|
204 |
+ * @param callable|null $callback |
|
205 |
+ * @param mixed $default |
|
206 |
+ * @return mixed |
|
207 |
+ * |
|
208 |
+ * @deprecated Arr::last() should be used directly instead. Will be removed in Laravel 6.0. |
|
209 |
+ */ |
|
210 |
+ function array_last($array, callable $callback = null, $default = null) |
|
211 |
+ { |
|
212 |
+ return Arr::last($array, $callback, $default); |
|
213 |
+ } |
|
214 |
+} |
|
215 |
+ |
|
216 |
+if (! function_exists('array_only')) { |
|
217 |
+ /** |
|
218 |
+ * Get a subset of the items from the given array. |
|
219 |
+ * |
|
220 |
+ * @param array $array |
|
221 |
+ * @param array|string $keys |
|
222 |
+ * @return array |
|
223 |
+ * |
|
224 |
+ * @deprecated Arr::only() should be used directly instead. Will be removed in Laravel 6.0. |
|
225 |
+ */ |
|
226 |
+ function array_only($array, $keys) |
|
227 |
+ { |
|
228 |
+ return Arr::only($array, $keys); |
|
229 |
+ } |
|
230 |
+} |
|
231 |
+ |
|
232 |
+if (! function_exists('array_pluck')) { |
|
233 |
+ /** |
|
234 |
+ * Pluck an array of values from an array. |
|
235 |
+ * |
|
236 |
+ * @param array $array |
|
237 |
+ * @param string|array $value |
|
238 |
+ * @param string|array|null $key |
|
239 |
+ * @return array |
|
240 |
+ * |
|
241 |
+ * @deprecated Arr::pluck() should be used directly instead. Will be removed in Laravel 6.0. |
|
242 |
+ */ |
|
243 |
+ function array_pluck($array, $value, $key = null) |
|
244 |
+ { |
|
245 |
+ return Arr::pluck($array, $value, $key); |
|
246 |
+ } |
|
247 |
+} |
|
248 |
+ |
|
249 |
+if (! function_exists('array_prepend')) { |
|
250 |
+ /** |
|
251 |
+ * Push an item onto the beginning of an array. |
|
252 |
+ * |
|
253 |
+ * @param array $array |
|
254 |
+ * @param mixed $value |
|
255 |
+ * @param mixed $key |
|
256 |
+ * @return array |
|
257 |
+ * |
|
258 |
+ * @deprecated Arr::prepend() should be used directly instead. Will be removed in Laravel 6.0. |
|
259 |
+ */ |
|
260 |
+ function array_prepend($array, $value, $key = null) |
|
261 |
+ { |
|
262 |
+ return Arr::prepend($array, $value, $key); |
|
263 |
+ } |
|
264 |
+} |
|
265 |
+ |
|
266 |
+if (! function_exists('array_pull')) { |
|
267 |
+ /** |
|
268 |
+ * Get a value from the array, and remove it. |
|
269 |
+ * |
|
270 |
+ * @param array $array |
|
271 |
+ * @param string $key |
|
272 |
+ * @param mixed $default |
|
273 |
+ * @return mixed |
|
274 |
+ * |
|
275 |
+ * @deprecated Arr::pull() should be used directly instead. Will be removed in Laravel 6.0. |
|
276 |
+ */ |
|
277 |
+ function array_pull(&$array, $key, $default = null) |
|
278 |
+ { |
|
279 |
+ return Arr::pull($array, $key, $default); |
|
280 |
+ } |
|
281 |
+} |
|
282 |
+ |
|
283 |
+if (! function_exists('array_random')) { |
|
284 |
+ /** |
|
285 |
+ * Get a random value from an array. |
|
286 |
+ * |
|
287 |
+ * @param array $array |
|
288 |
+ * @param int|null $num |
|
289 |
+ * @return mixed |
|
290 |
+ * |
|
291 |
+ * @deprecated Arr::random() should be used directly instead. Will be removed in Laravel 6.0. |
|
292 |
+ */ |
|
293 |
+ function array_random($array, $num = null) |
|
294 |
+ { |
|
295 |
+ return Arr::random($array, $num); |
|
296 |
+ } |
|
297 |
+} |
|
298 |
+ |
|
299 |
+if (! function_exists('array_set')) { |
|
300 |
+ /** |
|
301 |
+ * Set an array item to a given value using "dot" notation. |
|
302 |
+ * |
|
303 |
+ * If no key is given to the method, the entire array will be replaced. |
|
304 |
+ * |
|
305 |
+ * @param array $array |
|
306 |
+ * @param string $key |
|
307 |
+ * @param mixed $value |
|
308 |
+ * @return array |
|
309 |
+ * |
|
310 |
+ * @deprecated Arr::set() should be used directly instead. Will be removed in Laravel 6.0. |
|
311 |
+ */ |
|
312 |
+ function array_set(&$array, $key, $value) |
|
313 |
+ { |
|
314 |
+ return Arr::set($array, $key, $value); |
|
315 |
+ } |
|
316 |
+} |
|
317 |
+ |
|
318 |
+if (! function_exists('array_sort')) { |
|
319 |
+ /** |
|
320 |
+ * Sort the array by the given callback or attribute name. |
|
321 |
+ * |
|
322 |
+ * @param array $array |
|
323 |
+ * @param callable|string|null $callback |
|
324 |
+ * @return array |
|
325 |
+ * |
|
326 |
+ * @deprecated Arr::sort() should be used directly instead. Will be removed in Laravel 6.0. |
|
327 |
+ */ |
|
328 |
+ function array_sort($array, $callback = null) |
|
329 |
+ { |
|
330 |
+ return Arr::sort($array, $callback); |
|
331 |
+ } |
|
332 |
+} |
|
333 |
+ |
|
334 |
+if (! function_exists('array_sort_recursive')) { |
|
335 |
+ /** |
|
336 |
+ * Recursively sort an array by keys and values. |
|
337 |
+ * |
|
338 |
+ * @param array $array |
|
339 |
+ * @return array |
|
340 |
+ * |
|
341 |
+ * @deprecated Arr::sortRecursive() should be used directly instead. Will be removed in Laravel 6.0. |
|
342 |
+ */ |
|
343 |
+ function array_sort_recursive($array) |
|
344 |
+ { |
|
345 |
+ return Arr::sortRecursive($array); |
|
346 |
+ } |
|
347 |
+} |
|
348 |
+ |
|
349 |
+if (! function_exists('array_where')) { |
|
350 |
+ /** |
|
351 |
+ * Filter the array using the given callback. |
|
352 |
+ * |
|
353 |
+ * @param array $array |
|
354 |
+ * @param callable $callback |
|
355 |
+ * @return array |
|
356 |
+ * |
|
357 |
+ * @deprecated Arr::where() should be used directly instead. Will be removed in Laravel 6.0. |
|
358 |
+ */ |
|
359 |
+ function array_where($array, callable $callback) |
|
360 |
+ { |
|
361 |
+ return Arr::where($array, $callback); |
|
362 |
+ } |
|
363 |
+} |
|
364 |
+ |
|
365 |
+if (! function_exists('array_wrap')) { |
|
366 |
+ /** |
|
367 |
+ * If the given value is not an array, wrap it in one. |
|
368 |
+ * |
|
369 |
+ * @param mixed $value |
|
370 |
+ * @return array |
|
371 |
+ * |
|
372 |
+ * @deprecated Arr::wrap() should be used directly instead. Will be removed in Laravel 6.0. |
|
373 |
+ */ |
|
374 |
+ function array_wrap($value) |
|
375 |
+ { |
|
376 |
+ return Arr::wrap($value); |
|
377 |
+ } |
|
378 |
+} |
|
379 |
+ |
|
380 |
+if (! function_exists('blank')) { |
|
381 |
+ /** |
|
382 |
+ * Determine if the given value is "blank". |
|
383 |
+ * |
|
384 |
+ * @param mixed $value |
|
385 |
+ * @return bool |
|
386 |
+ */ |
|
387 |
+ function blank($value) |
|
388 |
+ { |
|
389 |
+ if (is_null($value)) { |
|
390 |
+ return true; |
|
391 |
+ } |
|
392 |
+ |
|
393 |
+ if (is_string($value)) { |
|
394 |
+ return trim($value) === ''; |
|
395 |
+ } |
|
396 |
+ |
|
397 |
+ if (is_numeric($value) || is_bool($value)) { |
|
398 |
+ return false; |
|
399 |
+ } |
|
400 |
+ |
|
401 |
+ if ($value instanceof Countable) { |
|
402 |
+ return count($value) === 0; |
|
403 |
+ } |
|
404 |
+ |
|
405 |
+ return empty($value); |
|
406 |
+ } |
|
407 |
+} |
|
408 |
+ |
|
409 |
+if (! function_exists('camel_case')) { |
|
410 |
+ /** |
|
411 |
+ * Convert a value to camel case. |
|
412 |
+ * |
|
413 |
+ * @param string $value |
|
414 |
+ * @return string |
|
415 |
+ * |
|
416 |
+ * @deprecated Str::camel() should be used directly instead. Will be removed in Laravel 6.0. |
|
417 |
+ */ |
|
418 |
+ function camel_case($value) |
|
419 |
+ { |
|
420 |
+ return Str::camel($value); |
|
421 |
+ } |
|
422 |
+} |
|
423 |
+ |
|
424 |
+if (! function_exists('class_basename')) { |
|
425 |
+ /** |
|
426 |
+ * Get the class "basename" of the given object / class. |
|
427 |
+ * |
|
428 |
+ * @param string|object $class |
|
429 |
+ * @return string |
|
430 |
+ */ |
|
431 |
+ function class_basename($class) |
|
432 |
+ { |
|
433 |
+ $class = is_object($class) ? get_class($class) : $class; |
|
434 |
+ |
|
435 |
+ return basename(str_replace('\\', '/', $class)); |
|
436 |
+ } |
|
437 |
+} |
|
438 |
+ |
|
439 |
+if (! function_exists('class_uses_recursive')) { |
|
440 |
+ /** |
|
441 |
+ * Returns all traits used by a class, its parent classes and trait of their traits. |
|
442 |
+ * |
|
443 |
+ * @param object|string $class |
|
444 |
+ * @return array |
|
445 |
+ */ |
|
446 |
+ function class_uses_recursive($class) |
|
447 |
+ { |
|
448 |
+ if (is_object($class)) { |
|
449 |
+ $class = get_class($class); |
|
450 |
+ } |
|
451 |
+ |
|
452 |
+ $results = []; |
|
453 |
+ |
|
454 |
+ foreach (array_reverse(class_parents($class)) + [$class => $class] as $class) { |
|
455 |
+ $results += trait_uses_recursive($class); |
|
456 |
+ } |
|
457 |
+ |
|
458 |
+ return array_unique($results); |
|
459 |
+ } |
|
460 |
+} |
|
461 |
+ |
|
462 |
+if (! function_exists('collect')) { |
|
463 |
+ /** |
|
464 |
+ * Create a collection from the given value. |
|
465 |
+ * |
|
466 |
+ * @param mixed $value |
|
467 |
+ * @return \Illuminate\Support\Collection |
|
468 |
+ */ |
|
469 |
+ function collect($value = null) |
|
470 |
+ { |
|
471 |
+ return new Collection($value); |
|
472 |
+ } |
|
473 |
+} |
|
474 |
+ |
|
475 |
+if (! function_exists('data_fill')) { |
|
476 |
+ /** |
|
477 |
+ * Fill in data where it's missing. |
|
478 |
+ * |
|
479 |
+ * @param mixed $target |
|
480 |
+ * @param string|array $key |
|
481 |
+ * @param mixed $value |
|
482 |
+ * @return mixed |
|
483 |
+ */ |
|
484 |
+ function data_fill(&$target, $key, $value) |
|
485 |
+ { |
|
486 |
+ return data_set($target, $key, $value, false); |
|
487 |
+ } |
|
488 |
+} |
|
489 |
+ |
|
490 |
+if (! function_exists('data_get')) { |
|
491 |
+ /** |
|
492 |
+ * Get an item from an array or object using "dot" notation. |
|
493 |
+ * |
|
494 |
+ * @param mixed $target |
|
495 |
+ * @param string|array|int $key |
|
496 |
+ * @param mixed $default |
|
497 |
+ * @return mixed |
|
498 |
+ */ |
|
499 |
+ function data_get($target, $key, $default = null) |
|
500 |
+ { |
|
501 |
+ if (is_null($key)) { |
|
502 |
+ return $target; |
|
503 |
+ } |
|
504 |
+ |
|
505 |
+ $key = is_array($key) ? $key : explode('.', $key); |
|
506 |
+ |
|
507 |
+ while (! is_null($segment = array_shift($key))) { |
|
508 |
+ if ($segment === '*') { |
|
509 |
+ if ($target instanceof Collection) { |
|
510 |
+ $target = $target->all(); |
|
511 |
+ } elseif (! is_array($target)) { |
|
512 |
+ return value($default); |
|
513 |
+ } |
|
514 |
+ |
|
515 |
+ $result = []; |
|
516 |
+ |
|
517 |
+ foreach ($target as $item) { |
|
518 |
+ $result[] = data_get($item, $key); |
|
519 |
+ } |
|
520 |
+ |
|
521 |
+ return in_array('*', $key) ? Arr::collapse($result) : $result; |
|
522 |
+ } |
|
523 |
+ |
|
524 |
+ if (Arr::accessible($target) && Arr::exists($target, $segment)) { |
|
525 |
+ $target = $target[$segment]; |
|
526 |
+ } elseif (is_object($target) && isset($target->{$segment})) { |
|
527 |
+ $target = $target->{$segment}; |
|
528 |
+ } else { |
|
529 |
+ return value($default); |
|
530 |
+ } |
|
531 |
+ } |
|
532 |
+ |
|
533 |
+ return $target; |
|
534 |
+ } |
|
535 |
+} |
|
536 |
+ |
|
537 |
+if (! function_exists('data_set')) { |
|
538 |
+ /** |
|
539 |
+ * Set an item on an array or object using dot notation. |
|
540 |
+ * |
|
541 |
+ * @param mixed $target |
|
542 |
+ * @param string|array $key |
|
543 |
+ * @param mixed $value |
|
544 |
+ * @param bool $overwrite |
|
545 |
+ * @return mixed |
|
546 |
+ */ |
|
547 |
+ function data_set(&$target, $key, $value, $overwrite = true) |
|
548 |
+ { |
|
549 |
+ $segments = is_array($key) ? $key : explode('.', $key); |
|
550 |
+ |
|
551 |
+ if (($segment = array_shift($segments)) === '*') { |
|
552 |
+ if (! Arr::accessible($target)) { |
|
553 |
+ $target = []; |
|
554 |
+ } |
|
555 |
+ |
|
556 |
+ if ($segments) { |
|
557 |
+ foreach ($target as &$inner) { |
|
558 |
+ data_set($inner, $segments, $value, $overwrite); |
|
559 |
+ } |
|
560 |
+ } elseif ($overwrite) { |
|
561 |
+ foreach ($target as &$inner) { |
|
562 |
+ $inner = $value; |
|
563 |
+ } |
|
564 |
+ } |
|
565 |
+ } elseif (Arr::accessible($target)) { |
|
566 |
+ if ($segments) { |
|
567 |
+ if (! Arr::exists($target, $segment)) { |
|
568 |
+ $target[$segment] = []; |
|
569 |
+ } |
|
570 |
+ |
|
571 |
+ data_set($target[$segment], $segments, $value, $overwrite); |
|
572 |
+ } elseif ($overwrite || ! Arr::exists($target, $segment)) { |
|
573 |
+ $target[$segment] = $value; |
|
574 |
+ } |
|
575 |
+ } elseif (is_object($target)) { |
|
576 |
+ if ($segments) { |
|
577 |
+ if (! isset($target->{$segment})) { |
|
578 |
+ $target->{$segment} = []; |
|
579 |
+ } |
|
580 |
+ |
|
581 |
+ data_set($target->{$segment}, $segments, $value, $overwrite); |
|
582 |
+ } elseif ($overwrite || ! isset($target->{$segment})) { |
|
583 |
+ $target->{$segment} = $value; |
|
584 |
+ } |
|
585 |
+ } else { |
|
586 |
+ $target = []; |
|
587 |
+ |
|
588 |
+ if ($segments) { |
|
589 |
+ data_set($target[$segment], $segments, $value, $overwrite); |
|
590 |
+ } elseif ($overwrite) { |
|
591 |
+ $target[$segment] = $value; |
|
592 |
+ } |
|
593 |
+ } |
|
594 |
+ |
|
595 |
+ return $target; |
|
596 |
+ } |
|
597 |
+} |
|
598 |
+ |
|
599 |
+if (! function_exists('e')) { |
|
600 |
+ /** |
|
601 |
+ * Encode HTML special characters in a string. |
|
602 |
+ * |
|
603 |
+ * @param \Illuminate\Contracts\Support\Htmlable|string $value |
|
604 |
+ * @param bool $doubleEncode |
|
605 |
+ * @return string |
|
606 |
+ */ |
|
607 |
+ function e($value, $doubleEncode = true) |
|
608 |
+ { |
|
609 |
+ if ($value instanceof Htmlable) { |
|
610 |
+ return $value->toHtml(); |
|
611 |
+ } |
|
612 |
+ |
|
613 |
+ return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', $doubleEncode); |
|
614 |
+ } |
|
615 |
+} |
|
616 |
+ |
|
617 |
+if (! function_exists('ends_with')) { |
|
618 |
+ /** |
|
619 |
+ * Determine if a given string ends with a given substring. |
|
620 |
+ * |
|
621 |
+ * @param string $haystack |
|
622 |
+ * @param string|array $needles |
|
623 |
+ * @return bool |
|
624 |
+ * |
|
625 |
+ * @deprecated Str::endsWith() should be used directly instead. Will be removed in Laravel 6.0. |
|
626 |
+ */ |
|
627 |
+ function ends_with($haystack, $needles) |
|
628 |
+ { |
|
629 |
+ return Str::endsWith($haystack, $needles); |
|
630 |
+ } |
|
631 |
+} |
|
632 |
+ |
|
633 |
+if (! function_exists('env')) { |
|
634 |
+ /** |
|
635 |
+ * Gets the value of an environment variable. |
|
636 |
+ * |
|
637 |
+ * @param string $key |
|
638 |
+ * @param mixed $default |
|
639 |
+ * @return mixed |
|
640 |
+ */ |
|
641 |
+ function env($key, $default = null) |
|
642 |
+ { |
|
643 |
+ static $variables; |
|
644 |
+ |
|
645 |
+ if ($variables === null) { |
|
646 |
+ $variables = (new DotenvFactory([new EnvConstAdapter, new PutenvAdapter, new ServerConstAdapter]))->createImmutable(); |
|
647 |
+ } |
|
648 |
+ |
|
649 |
+ return Option::fromValue($variables->get($key)) |
|
650 |
+ ->map(function ($value) { |
|
651 |
+ switch (strtolower($value)) { |
|
652 |
+ case 'true': |
|
653 |
+ case '(true)': |
|
654 |
+ return true; |
|
655 |
+ case 'false': |
|
656 |
+ case '(false)': |
|
657 |
+ return false; |
|
658 |
+ case 'empty': |
|
659 |
+ case '(empty)': |
|
660 |
+ return ''; |
|
661 |
+ case 'null': |
|
662 |
+ case '(null)': |
|
663 |
+ return; |
|
664 |
+ } |
|
665 |
+ |
|
666 |
+ if (preg_match('/\A([\'"])(.*)\1\z/', $value, $matches)) { |
|
667 |
+ return $matches[2]; |
|
668 |
+ } |
|
669 |
+ |
|
670 |
+ return $value; |
|
671 |
+ }) |
|
672 |
+ ->getOrCall(function () use ($default) { |
|
673 |
+ return value($default); |
|
674 |
+ }); |
|
675 |
+ } |
|
676 |
+} |
|
677 |
+ |
|
678 |
+if (! function_exists('filled')) { |
|
679 |
+ /** |
|
680 |
+ * Determine if a value is "filled". |
|
681 |
+ * |
|
682 |
+ * @param mixed $value |
|
683 |
+ * @return bool |
|
684 |
+ */ |
|
685 |
+ function filled($value) |
|
686 |
+ { |
|
687 |
+ return ! blank($value); |
|
688 |
+ } |
|
689 |
+} |
|
690 |
+ |
|
691 |
+if (! function_exists('head')) { |
|
692 |
+ /** |
|
693 |
+ * Get the first element of an array. Useful for method chaining. |
|
694 |
+ * |
|
695 |
+ * @param array $array |
|
696 |
+ * @return mixed |
|
697 |
+ */ |
|
698 |
+ function head($array) |
|
699 |
+ { |
|
700 |
+ return reset($array); |
|
701 |
+ } |
|
702 |
+} |
|
703 |
+ |
|
704 |
+if (! function_exists('kebab_case')) { |
|
705 |
+ /** |
|
706 |
+ * Convert a string to kebab case. |
|
707 |
+ * |
|
708 |
+ * @param string $value |
|
709 |
+ * @return string |
|
710 |
+ * |
|
711 |
+ * @deprecated Str::kebab() should be used directly instead. Will be removed in Laravel 6.0. |
|
712 |
+ */ |
|
713 |
+ function kebab_case($value) |
|
714 |
+ { |
|
715 |
+ return Str::kebab($value); |
|
716 |
+ } |
|
717 |
+} |
|
718 |
+ |
|
719 |
+if (! function_exists('last')) { |
|
720 |
+ /** |
|
721 |
+ * Get the last element from an array. |
|
722 |
+ * |
|
723 |
+ * @param array $array |
|
724 |
+ * @return mixed |
|
725 |
+ */ |
|
726 |
+ function last($array) |
|
727 |
+ { |
|
728 |
+ return end($array); |
|
729 |
+ } |
|
730 |
+} |
|
731 |
+ |
|
732 |
+if (! function_exists('object_get')) { |
|
733 |
+ /** |
|
734 |
+ * Get an item from an object using "dot" notation. |
|
735 |
+ * |
|
736 |
+ * @param object $object |
|
737 |
+ * @param string $key |
|
738 |
+ * @param mixed $default |
|
739 |
+ * @return mixed |
|
740 |
+ */ |
|
741 |
+ function object_get($object, $key, $default = null) |
|
742 |
+ { |
|
743 |
+ if (is_null($key) || trim($key) == '') { |
|
744 |
+ return $object; |
|
745 |
+ } |
|
746 |
+ |
|
747 |
+ foreach (explode('.', $key) as $segment) { |
|
748 |
+ if (! is_object($object) || ! isset($object->{$segment})) { |
|
749 |
+ return value($default); |
|
750 |
+ } |
|
751 |
+ |
|
752 |
+ $object = $object->{$segment}; |
|
753 |
+ } |
|
754 |
+ |
|
755 |
+ return $object; |
|
756 |
+ } |
|
757 |
+} |
|
758 |
+ |
|
759 |
+if (! function_exists('optional')) { |
|
760 |
+ /** |
|
761 |
+ * Provide access to optional objects. |
|
762 |
+ * |
|
763 |
+ * @param mixed $value |
|
764 |
+ * @param callable|null $callback |
|
765 |
+ * @return mixed |
|
766 |
+ */ |
|
767 |
+ function optional($value = null, callable $callback = null) |
|
768 |
+ { |
|
769 |
+ if (is_null($callback)) { |
|
770 |
+ return new Optional($value); |
|
771 |
+ } elseif (! is_null($value)) { |
|
772 |
+ return $callback($value); |
|
773 |
+ } |
|
774 |
+ } |
|
775 |
+} |
|
776 |
+ |
|
777 |
+if (! function_exists('preg_replace_array')) { |
|
778 |
+ /** |
|
779 |
+ * Replace a given pattern with each value in the array in sequentially. |
|
780 |
+ * |
|
781 |
+ * @param string $pattern |
|
782 |
+ * @param array $replacements |
|
783 |
+ * @param string $subject |
|
784 |
+ * @return string |
|
785 |
+ */ |
|
786 |
+ function preg_replace_array($pattern, array $replacements, $subject) |
|
787 |
+ { |
|
788 |
+ return preg_replace_callback($pattern, function () use (&$replacements) { |
|
789 |
+ foreach ($replacements as $key => $value) { |
|
790 |
+ return array_shift($replacements); |
|
791 |
+ } |
|
792 |
+ }, $subject); |
|
793 |
+ } |
|
794 |
+} |
|
795 |
+ |
|
796 |
+if (! function_exists('retry')) { |
|
797 |
+ /** |
|
798 |
+ * Retry an operation a given number of times. |
|
799 |
+ * |
|
800 |
+ * @param int $times |
|
801 |
+ * @param callable $callback |
|
802 |
+ * @param int $sleep |
|
803 |
+ * @param callable $when |
|
804 |
+ * @return mixed |
|
805 |
+ * |
|
806 |
+ * @throws \Exception |
|
807 |
+ */ |
|
808 |
+ function retry($times, callable $callback, $sleep = 0, $when = null) |
|
809 |
+ { |
|
810 |
+ $attempts = 0; |
|
811 |
+ $times--; |
|
812 |
+ |
|
813 |
+ beginning: |
|
814 |
+ $attempts++; |
|
815 |
+ |
|
816 |
+ try { |
|
817 |
+ return $callback($attempts); |
|
818 |
+ } catch (Exception $e) { |
|
819 |
+ if (! $times || ($when && ! $when($e))) { |
|
820 |
+ throw $e; |
|
821 |
+ } |
|
822 |
+ |
|
823 |
+ $times--; |
|
824 |
+ |
|
825 |
+ if ($sleep) { |
|
826 |
+ usleep($sleep * 1000); |
|
827 |
+ } |
|
828 |
+ |
|
829 |
+ goto beginning; |
|
830 |
+ } |
|
831 |
+ } |
|
832 |
+} |
|
833 |
+ |
|
834 |
+if (! function_exists('snake_case')) { |
|
835 |
+ /** |
|
836 |
+ * Convert a string to snake case. |
|
837 |
+ * |
|
838 |
+ * @param string $value |
|
839 |
+ * @param string $delimiter |
|
840 |
+ * @return string |
|
841 |
+ * |
|
842 |
+ * @deprecated Str::snake() should be used directly instead. Will be removed in Laravel 6.0. |
|
843 |
+ */ |
|
844 |
+ function snake_case($value, $delimiter = '_') |
|
845 |
+ { |
|
846 |
+ return Str::snake($value, $delimiter); |
|
847 |
+ } |
|
848 |
+} |
|
849 |
+ |
|
850 |
+if (! function_exists('starts_with')) { |
|
851 |
+ /** |
|
852 |
+ * Determine if a given string starts with a given substring. |
|
853 |
+ * |
|
854 |
+ * @param string $haystack |
|
855 |
+ * @param string|array $needles |
|
856 |
+ * @return bool |
|
857 |
+ * |
|
858 |
+ * @deprecated Str::startsWith() should be used directly instead. Will be removed in Laravel 6.0. |
|
859 |
+ */ |
|
860 |
+ function starts_with($haystack, $needles) |
|
861 |
+ { |
|
862 |
+ return Str::startsWith($haystack, $needles); |
|
863 |
+ } |
|
864 |
+} |
|
865 |
+ |
|
866 |
+if (! function_exists('str_after')) { |
|
867 |
+ /** |
|
868 |
+ * Return the remainder of a string after a given value. |
|
869 |
+ * |
|
870 |
+ * @param string $subject |
|
871 |
+ * @param string $search |
|
872 |
+ * @return string |
|
873 |
+ * |
|
874 |
+ * @deprecated Str::after() should be used directly instead. Will be removed in Laravel 6.0. |
|
875 |
+ */ |
|
876 |
+ function str_after($subject, $search) |
|
877 |
+ { |
|
878 |
+ return Str::after($subject, $search); |
|
879 |
+ } |
|
880 |
+} |
|
881 |
+ |
|
882 |
+if (! function_exists('str_before')) { |
|
883 |
+ /** |
|
884 |
+ * Get the portion of a string before a given value. |
|
885 |
+ * |
|
886 |
+ * @param string $subject |
|
887 |
+ * @param string $search |
|
888 |
+ * @return string |
|
889 |
+ * |
|
890 |
+ * @deprecated Str::before() should be used directly instead. Will be removed in Laravel 6.0. |
|
891 |
+ */ |
|
892 |
+ function str_before($subject, $search) |
|
893 |
+ { |
|
894 |
+ return Str::before($subject, $search); |
|
895 |
+ } |
|
896 |
+} |
|
897 |
+ |
|
898 |
+if (! function_exists('str_contains')) { |
|
899 |
+ /** |
|
900 |
+ * Determine if a given string contains a given substring. |
|
901 |
+ * |
|
902 |
+ * @param string $haystack |
|
903 |
+ * @param string|array $needles |
|
904 |
+ * @return bool |
|
905 |
+ * |
|
906 |
+ * @deprecated Str::contains() should be used directly instead. Will be removed in Laravel 6.0. |
|
907 |
+ */ |
|
908 |
+ function str_contains($haystack, $needles) |
|
909 |
+ { |
|
910 |
+ return Str::contains($haystack, $needles); |
|
911 |
+ } |
|
912 |
+} |
|
913 |
+ |
|
914 |
+if (! function_exists('str_finish')) { |
|
915 |
+ /** |
|
916 |
+ * Cap a string with a single instance of a given value. |
|
917 |
+ * |
|
918 |
+ * @param string $value |
|
919 |
+ * @param string $cap |
|
920 |
+ * @return string |
|
921 |
+ * |
|
922 |
+ * @deprecated Str::finish() should be used directly instead. Will be removed in Laravel 6.0. |
|
923 |
+ */ |
|
924 |
+ function str_finish($value, $cap) |
|
925 |
+ { |
|
926 |
+ return Str::finish($value, $cap); |
|
927 |
+ } |
|
928 |
+} |
|
929 |
+ |
|
930 |
+if (! function_exists('str_is')) { |
|
931 |
+ /** |
|
932 |
+ * Determine if a given string matches a given pattern. |
|
933 |
+ * |
|
934 |
+ * @param string|array $pattern |
|
935 |
+ * @param string $value |
|
936 |
+ * @return bool |
|
937 |
+ * |
|
938 |
+ * @deprecated Str::is() should be used directly instead. Will be removed in Laravel 6.0. |
|
939 |
+ */ |
|
940 |
+ function str_is($pattern, $value) |
|
941 |
+ { |
|
942 |
+ return Str::is($pattern, $value); |
|
943 |
+ } |
|
944 |
+} |
|
945 |
+ |
|
946 |
+if (! function_exists('str_limit')) { |
|
947 |
+ /** |
|
948 |
+ * Limit the number of characters in a string. |
|
949 |
+ * |
|
950 |
+ * @param string $value |
|
951 |
+ * @param int $limit |
|
952 |
+ * @param string $end |
|
953 |
+ * @return string |
|
954 |
+ * |
|
955 |
+ * @deprecated Str::limit() should be used directly instead. Will be removed in Laravel 6.0. |
|
956 |
+ */ |
|
957 |
+ function str_limit($value, $limit = 100, $end = '...') |
|
958 |
+ { |
|
959 |
+ return Str::limit($value, $limit, $end); |
|
960 |
+ } |
|
961 |
+} |
|
962 |
+ |
|
963 |
+if (! function_exists('str_plural')) { |
|
964 |
+ /** |
|
965 |
+ * Get the plural form of an English word. |
|
966 |
+ * |
|
967 |
+ * @param string $value |
|
968 |
+ * @param int $count |
|
969 |
+ * @return string |
|
970 |
+ * |
|
971 |
+ * @deprecated Str::plural() should be used directly instead. Will be removed in Laravel 6.0. |
|
972 |
+ */ |
|
973 |
+ function str_plural($value, $count = 2) |
|
974 |
+ { |
|
975 |
+ return Str::plural($value, $count); |
|
976 |
+ } |
|
977 |
+} |
|
978 |
+ |
|
979 |
+if (! function_exists('str_random')) { |
|
980 |
+ /** |
|
981 |
+ * Generate a more truly "random" alpha-numeric string. |
|
982 |
+ * |
|
983 |
+ * @param int $length |
|
984 |
+ * @return string |
|
985 |
+ * |
|
986 |
+ * @throws \RuntimeException |
|
987 |
+ * |
|
988 |
+ * @deprecated Str::random() should be used directly instead. Will be removed in Laravel 6.0. |
|
989 |
+ */ |
|
990 |
+ function str_random($length = 16) |
|
991 |
+ { |
|
992 |
+ return Str::random($length); |
|
993 |
+ } |
|
994 |
+} |
|
995 |
+ |
|
996 |
+if (! function_exists('str_replace_array')) { |
|
997 |
+ /** |
|
998 |
+ * Replace a given value in the string sequentially with an array. |
|
999 |
+ * |
|
1000 |
+ * @param string $search |
|
1001 |
+ * @param array $replace |
|
1002 |
+ * @param string $subject |
|
1003 |
+ * @return string |
|
1004 |
+ * |
|
1005 |
+ * @deprecated Str::replaceArray() should be used directly instead. Will be removed in Laravel 6.0. |
|
1006 |
+ */ |
|
1007 |
+ function str_replace_array($search, array $replace, $subject) |
|
1008 |
+ { |
|
1009 |
+ return Str::replaceArray($search, $replace, $subject); |
|
1010 |
+ } |
|
1011 |
+} |
|
1012 |
+ |
|
1013 |
+if (! function_exists('str_replace_first')) { |
|
1014 |
+ /** |
|
1015 |
+ * Replace the first occurrence of a given value in the string. |
|
1016 |
+ * |
|
1017 |
+ * @param string $search |
|
1018 |
+ * @param string $replace |
|
1019 |
+ * @param string $subject |
|
1020 |
+ * @return string |
|
1021 |
+ * |
|
1022 |
+ * @deprecated Str::replaceFirst() should be used directly instead. Will be removed in Laravel 6.0. |
|
1023 |
+ */ |
|
1024 |
+ function str_replace_first($search, $replace, $subject) |
|
1025 |
+ { |
|
1026 |
+ return Str::replaceFirst($search, $replace, $subject); |
|
1027 |
+ } |
|
1028 |
+} |
|
1029 |
+ |
|
1030 |
+if (! function_exists('str_replace_last')) { |
|
1031 |
+ /** |
|
1032 |
+ * Replace the last occurrence of a given value in the string. |
|
1033 |
+ * |
|
1034 |
+ * @param string $search |
|
1035 |
+ * @param string $replace |
|
1036 |
+ * @param string $subject |
|
1037 |
+ * @return string |
|
1038 |
+ * |
|
1039 |
+ * @deprecated Str::replaceLast() should be used directly instead. Will be removed in Laravel 6.0. |
|
1040 |
+ */ |
|
1041 |
+ function str_replace_last($search, $replace, $subject) |
|
1042 |
+ { |
|
1043 |
+ return Str::replaceLast($search, $replace, $subject); |
|
1044 |
+ } |
|
1045 |
+} |
|
1046 |
+ |
|
1047 |
+if (! function_exists('str_singular')) { |
|
1048 |
+ /** |
|
1049 |
+ * Get the singular form of an English word. |
|
1050 |
+ * |
|
1051 |
+ * @param string $value |
|
1052 |
+ * @return string |
|
1053 |
+ * |
|
1054 |
+ * @deprecated Str::singular() should be used directly instead. Will be removed in Laravel 6.0. |
|
1055 |
+ */ |
|
1056 |
+ function str_singular($value) |
|
1057 |
+ { |
|
1058 |
+ return Str::singular($value); |
|
1059 |
+ } |
|
1060 |
+} |
|
1061 |
+ |
|
1062 |
+if (! function_exists('str_slug')) { |
|
1063 |
+ /** |
|
1064 |
+ * Generate a URL friendly "slug" from a given string. |
|
1065 |
+ * |
|
1066 |
+ * @param string $title |
|
1067 |
+ * @param string $separator |
|
1068 |
+ * @param string $language |
|
1069 |
+ * @return string |
|
1070 |
+ * |
|
1071 |
+ * @deprecated Str::slug() should be used directly instead. Will be removed in Laravel 6.0. |
|
1072 |
+ */ |
|
1073 |
+ function str_slug($title, $separator = '-', $language = 'en') |
|
1074 |
+ { |
|
1075 |
+ return Str::slug($title, $separator, $language); |
|
1076 |
+ } |
|
1077 |
+} |
|
1078 |
+ |
|
1079 |
+if (! function_exists('str_start')) { |
|
1080 |
+ /** |
|
1081 |
+ * Begin a string with a single instance of a given value. |
|
1082 |
+ * |
|
1083 |
+ * @param string $value |
|
1084 |
+ * @param string $prefix |
|
1085 |
+ * @return string |
|
1086 |
+ * |
|
1087 |
+ * @deprecated Str::start() should be used directly instead. Will be removed in Laravel 6.0. |
|
1088 |
+ */ |
|
1089 |
+ function str_start($value, $prefix) |
|
1090 |
+ { |
|
1091 |
+ return Str::start($value, $prefix); |
|
1092 |
+ } |
|
1093 |
+} |
|
1094 |
+ |
|
1095 |
+if (! function_exists('studly_case')) { |
|
1096 |
+ /** |
|
1097 |
+ * Convert a value to studly caps case. |
|
1098 |
+ * |
|
1099 |
+ * @param string $value |
|
1100 |
+ * @return string |
|
1101 |
+ * |
|
1102 |
+ * @deprecated Str::studly() should be used directly instead. Will be removed in Laravel 6.0. |
|
1103 |
+ */ |
|
1104 |
+ function studly_case($value) |
|
1105 |
+ { |
|
1106 |
+ return Str::studly($value); |
|
1107 |
+ } |
|
1108 |
+} |
|
1109 |
+ |
|
1110 |
+if (! function_exists('tap')) { |
|
1111 |
+ /** |
|
1112 |
+ * Call the given Closure with the given value then return the value. |
|
1113 |
+ * |
|
1114 |
+ * @param mixed $value |
|
1115 |
+ * @param callable|null $callback |
|
1116 |
+ * @return mixed |
|
1117 |
+ */ |
|
1118 |
+ function tap($value, $callback = null) |
|
1119 |
+ { |
|
1120 |
+ if (is_null($callback)) { |
|
1121 |
+ return new HigherOrderTapProxy($value); |
|
1122 |
+ } |
|
1123 |
+ |
|
1124 |
+ $callback($value); |
|
1125 |
+ |
|
1126 |
+ return $value; |
|
1127 |
+ } |
|
1128 |
+} |
|
1129 |
+ |
|
1130 |
+if (! function_exists('throw_if')) { |
|
1131 |
+ /** |
|
1132 |
+ * Throw the given exception if the given condition is true. |
|
1133 |
+ * |
|
1134 |
+ * @param mixed $condition |
|
1135 |
+ * @param \Throwable|string $exception |
|
1136 |
+ * @param array ...$parameters |
|
1137 |
+ * @return mixed |
|
1138 |
+ * |
|
1139 |
+ * @throws \Throwable |
|
1140 |
+ */ |
|
1141 |
+ function throw_if($condition, $exception, ...$parameters) |
|
1142 |
+ { |
|
1143 |
+ if ($condition) { |
|
1144 |
+ throw (is_string($exception) ? new $exception(...$parameters) : $exception); |
|
1145 |
+ } |
|
1146 |
+ |
|
1147 |
+ return $condition; |
|
1148 |
+ } |
|
1149 |
+} |
|
1150 |
+ |
|
1151 |
+if (! function_exists('throw_unless')) { |
|
1152 |
+ /** |
|
1153 |
+ * Throw the given exception unless the given condition is true. |
|
1154 |
+ * |
|
1155 |
+ * @param mixed $condition |
|
1156 |
+ * @param \Throwable|string $exception |
|
1157 |
+ * @param array ...$parameters |
|
1158 |
+ * @return mixed |
|
1159 |
+ * @throws \Throwable |
|
1160 |
+ */ |
|
1161 |
+ function throw_unless($condition, $exception, ...$parameters) |
|
1162 |
+ { |
|
1163 |
+ if (! $condition) { |
|
1164 |
+ throw (is_string($exception) ? new $exception(...$parameters) : $exception); |
|
1165 |
+ } |
|
1166 |
+ |
|
1167 |
+ return $condition; |
|
1168 |
+ } |
|
1169 |
+} |
|
1170 |
+ |
|
1171 |
+if (! function_exists('title_case')) { |
|
1172 |
+ /** |
|
1173 |
+ * Convert a value to title case. |
|
1174 |
+ * |
|
1175 |
+ * @param string $value |
|
1176 |
+ * @return string |
|
1177 |
+ * |
|
1178 |
+ * @deprecated Str::title() should be used directly instead. Will be removed in Laravel 6.0. |
|
1179 |
+ */ |
|
1180 |
+ function title_case($value) |
|
1181 |
+ { |
|
1182 |
+ return Str::title($value); |
|
1183 |
+ } |
|
1184 |
+} |
|
1185 |
+ |
|
1186 |
+if (! function_exists('trait_uses_recursive')) { |
|
1187 |
+ /** |
|
1188 |
+ * Returns all traits used by a trait and its traits. |
|
1189 |
+ * |
|
1190 |
+ * @param string $trait |
|
1191 |
+ * @return array |
|
1192 |
+ */ |
|
1193 |
+ function trait_uses_recursive($trait) |
|
1194 |
+ { |
|
1195 |
+ $traits = class_uses($trait); |
|
1196 |
+ |
|
1197 |
+ foreach ($traits as $trait) { |
|
1198 |
+ $traits += trait_uses_recursive($trait); |
|
1199 |
+ } |
|
1200 |
+ |
|
1201 |
+ return $traits; |
|
1202 |
+ } |
|
1203 |
+} |
|
1204 |
+ |
|
1205 |
+if (! function_exists('transform')) { |
|
1206 |
+ /** |
|
1207 |
+ * Transform the given value if it is present. |
|
1208 |
+ * |
|
1209 |
+ * @param mixed $value |
|
1210 |
+ * @param callable $callback |
|
1211 |
+ * @param mixed $default |
|
1212 |
+ * @return mixed|null |
|
1213 |
+ */ |
|
1214 |
+ function transform($value, callable $callback, $default = null) |
|
1215 |
+ { |
|
1216 |
+ if (filled($value)) { |
|
1217 |
+ return $callback($value); |
|
1218 |
+ } |
|
1219 |
+ |
|
1220 |
+ if (is_callable($default)) { |
|
1221 |
+ return $default($value); |
|
1222 |
+ } |
|
1223 |
+ |
|
1224 |
+ return $default; |
|
1225 |
+ } |
|
1226 |
+} |
|
1227 |
+ |
|
1228 |
+if (! function_exists('value')) { |
|
1229 |
+ /** |
|
1230 |
+ * Return the default value of the given value. |
|
1231 |
+ * |
|
1232 |
+ * @param mixed $value |
|
1233 |
+ * @return mixed |
|
1234 |
+ */ |
|
1235 |
+ function value($value) |
|
1236 |
+ { |
|
1237 |
+ return $value instanceof Closure ? $value() : $value; |
|
1238 |
+ } |
|
1239 |
+} |
|
1240 |
+ |
|
1241 |
+if (! function_exists('windows_os')) { |
|
1242 |
+ /** |
|
1243 |
+ * Determine whether the current environment is Windows based. |
|
1244 |
+ * |
|
1245 |
+ * @return bool |
|
1246 |
+ */ |
|
1247 |
+ function windows_os() |
|
1248 |
+ { |
|
1249 |
+ return strtolower(substr(PHP_OS, 0, 3)) === 'win'; |
|
1250 |
+ } |
|
1251 |
+} |
|
1252 |
+ |
|
1253 |
+if (! function_exists('with')) { |
|
1254 |
+ /** |
|
1255 |
+ * Return the given value, optionally passed through the given callback. |
|
1256 |
+ * |
|
1257 |
+ * @param mixed $value |
|
1258 |
+ * @param callable|null $callback |
|
1259 |
+ * @return mixed |
|
1260 |
+ */ |
|
1261 |
+ function with($value, callable $callback = null) |
|
1262 |
+ { |
|
1263 |
+ return is_null($callback) ? $value : $callback($value); |
|
1264 |
+ } |
|
1265 |
+} |