@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct($path) |
24 | 24 | { |
25 | - $this->path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
25 | + $this->path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function getValue($chatId, $value, $default) |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | private function getFileName($chatId) |
46 | 46 | { |
47 | - return $this->path . 'c' . $chatId; |
|
47 | + return $this->path.'c'.$chatId; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function setValue($chatId, $key, $value) |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $map = $this->map; |
50 | 50 | |
51 | 51 | return collect($attributes) |
52 | - ->mapWithKeys(function ($item, $key) use ($map) { |
|
52 | + ->mapWithKeys(function($item, $key) use ($map) { |
|
53 | 53 | $keyData = array_get($map, $key); |
54 | 54 | if (is_callable($keyData)) { |
55 | 55 | return [$key => call_user_func($keyData, $item)]; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function toArray() |
82 | 82 | { |
83 | 83 | return $this->attributes |
84 | - ->mapWithKeys(function ($item, $key) { |
|
84 | + ->mapWithKeys(function($item, $key) { |
|
85 | 85 | if (is_subclass_of($item, BaseType::class)) { |
86 | 86 | /** @var BaseType $item */ |
87 | 87 | return [$key => $item->toArray()]; |
@@ -73,6 +73,9 @@ |
||
73 | 73 | return new static(is_array($json) ? $json : json_decode($json, true)); |
74 | 74 | } |
75 | 75 | |
76 | + /** |
|
77 | + * @param string $key |
|
78 | + */ |
|
76 | 79 | public function get($key) |
77 | 80 | { |
78 | 81 | return $this->attributes->get($key); |
@@ -39,7 +39,7 @@ |
||
39 | 39 | return $keyboard; |
40 | 40 | } |
41 | 41 | |
42 | - public function toArray(){ |
|
42 | + public function toArray() { |
|
43 | 43 | return $this->rows->toArray(); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -28,7 +28,7 @@ |
||
28 | 28 | { |
29 | 29 | $baseType = $this->baseType; |
30 | 30 | $this->array = collect($array) |
31 | - ->map(function ($item) use ($baseType) { |
|
31 | + ->map(function($item) use ($baseType) { |
|
32 | 32 | return new BaseType($item); |
33 | 33 | }); |
34 | 34 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (!$this->token) { |
48 | 48 | throw new TelegramCoreException('Token must be defined'); |
49 | 49 | } |
50 | - $baseOptions = [ |
|
50 | + $baseOptions = [ |
|
51 | 51 | 'base_uri' => sprintf('https://api.telegram.org/bot%s/', $token), |
52 | 52 | 'verify' => false, |
53 | 53 | 'http_errors' => false, |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $json = \GuzzleHttp\json_decode($response->getBody()->getContents(), true); |
82 | 82 | if (array_get($json, 'ok') == false) { |
83 | - throw new TelegramCoreException(array_get($json, 'description', 'error') . array_get($json, 'error_code'), |
|
83 | + throw new TelegramCoreException(array_get($json, 'description', 'error').array_get($json, 'error_code'), |
|
84 | 84 | array_get($json, 'error_code')); |
85 | 85 | } |
86 | 86 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | return $this->set('request_contact', $requestContact); |
42 | 42 | } |
43 | 43 | |
44 | - public function setRequestLocation(bool $requestLocation){ |
|
44 | + public function setRequestLocation(bool $requestLocation) { |
|
45 | 45 | return $this->set('request_contact', $requestLocation); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -77,10 +77,10 @@ |
||
77 | 77 | $clone = clone $this; |
78 | 78 | $rows = $clone |
79 | 79 | ->get(self::KEYBOARD_KEY, collect()) |
80 | - ->mapWithKeys(function ($item, $key) { |
|
80 | + ->mapWithKeys(function($item, $key) { |
|
81 | 81 | return [ |
82 | 82 | $key => collect($item) |
83 | - ->mapWithKeys(function ($item, $key) { |
|
83 | + ->mapWithKeys(function($item, $key) { |
|
84 | 84 | return [$key => $item->toArray()]; |
85 | 85 | }), |
86 | 86 | ]; |
@@ -38,10 +38,9 @@ |
||
38 | 38 | public function toArray() |
39 | 39 | { |
40 | 40 | return $this->attributes |
41 | - ->mapWithKeys(function ($item, $key) { |
|
42 | - return $item instanceof Collection || get_parent_class($item) === BaseEntry::class? |
|
43 | - [$key => $item->toArray()] : |
|
44 | - [$key => $item]; |
|
41 | + ->mapWithKeys(function($item, $key) { |
|
42 | + return $item instanceof Collection || get_parent_class($item) === BaseEntry::class ? |
|
43 | + [$key => $item->toArray()] : [$key => $item]; |
|
45 | 44 | }) |
46 | 45 | ->toArray(); |
47 | 46 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * [email protected] |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! function_exists('append_config')) |
|
9 | +if (!function_exists('append_config')) |
|
10 | 10 | { |
11 | 11 | /** |
12 | 12 | * Assign high numeric IDs to a config item to force appending. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -if ( ! function_exists('array_add')) |
|
35 | +if (!function_exists('array_add')) |
|
36 | 36 | { |
37 | 37 | /** |
38 | 38 | * Add an element to an array using "dot" notation if it doesn't exist. |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | -if ( ! function_exists('array_build')) |
|
56 | +if (!function_exists('array_build')) |
|
57 | 57 | { |
58 | 58 | /** |
59 | 59 | * Build a new array using a callback. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | -if ( ! function_exists('array_divide')) |
|
80 | +if (!function_exists('array_divide')) |
|
81 | 81 | { |
82 | 82 | /** |
83 | 83 | * Divide an array into two arrays. One with keys and the other with values. |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | -if ( ! function_exists('array_dot')) |
|
94 | +if (!function_exists('array_dot')) |
|
95 | 95 | { |
96 | 96 | /** |
97 | 97 | * Flatten a multi-dimensional associative array with dots. |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | -if ( ! function_exists('array_except')) |
|
123 | +if (!function_exists('array_except')) |
|
124 | 124 | { |
125 | 125 | /** |
126 | 126 | * Get all of the given array except for a specified array of items. |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | -if ( ! function_exists('array_fetch')) |
|
138 | +if (!function_exists('array_fetch')) |
|
139 | 139 | { |
140 | 140 | /** |
141 | 141 | * Fetch a flattened array of a nested array element. |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | -if ( ! function_exists('array_first')) |
|
168 | +if (!function_exists('array_first')) |
|
169 | 169 | { |
170 | 170 | /** |
171 | 171 | * Return the first element in an array passing a given truth test. |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | -if ( ! function_exists('array_last')) |
|
189 | +if (!function_exists('array_last')) |
|
190 | 190 | { |
191 | 191 | /** |
192 | 192 | * Return the last element in an array passing a given truth test. |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | -if ( ! function_exists('array_flatten')) |
|
205 | +if (!function_exists('array_flatten')) |
|
206 | 206 | { |
207 | 207 | /** |
208 | 208 | * Flatten a multi-dimensional array into a single level. |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | -if ( ! function_exists('array_forget')) |
|
223 | +if (!function_exists('array_forget')) |
|
224 | 224 | { |
225 | 225 | /** |
226 | 226 | * Remove one or many array items from a given array using "dot" notation. |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | function array_forget(&$array, $keys) |
233 | 233 | { |
234 | - $original =& $array; |
|
234 | + $original = & $array; |
|
235 | 235 | |
236 | 236 | foreach ((array) $keys as $key) |
237 | 237 | { |
@@ -243,19 +243,19 @@ discard block |
||
243 | 243 | |
244 | 244 | if (isset($array[$part]) && is_array($array[$part])) |
245 | 245 | { |
246 | - $array =& $array[$part]; |
|
246 | + $array = & $array[$part]; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | 250 | unset($array[array_shift($parts)]); |
251 | 251 | |
252 | 252 | // clean up after each pass |
253 | - $array =& $original; |
|
253 | + $array = & $original; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | -if ( ! function_exists('array_get')) |
|
258 | +if (!function_exists('array_get')) |
|
259 | 259 | { |
260 | 260 | /** |
261 | 261 | * Get an item from an array using "dot" notation. |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | foreach (explode('.', $key) as $segment) |
275 | 275 | { |
276 | - if ( ! is_array($array) || ! array_key_exists($segment, $array)) |
|
276 | + if (!is_array($array) || !array_key_exists($segment, $array)) |
|
277 | 277 | { |
278 | 278 | return value($default); |
279 | 279 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | -if ( ! function_exists('array_has')) |
|
288 | +if (!function_exists('array_has')) |
|
289 | 289 | { |
290 | 290 | /** |
291 | 291 | * Check if an item exists in an array using "dot" notation. |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | foreach (explode('.', $key) as $segment) |
304 | 304 | { |
305 | - if ( ! is_array($array) || ! array_key_exists($segment, $array)) |
|
305 | + if (!is_array($array) || !array_key_exists($segment, $array)) |
|
306 | 306 | { |
307 | 307 | return false; |
308 | 308 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | -if ( ! function_exists('array_only')) |
|
317 | +if (!function_exists('array_only')) |
|
318 | 318 | { |
319 | 319 | /** |
320 | 320 | * Get a subset of the items from the given array. |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | -if ( ! function_exists('array_pluck')) |
|
332 | +if (!function_exists('array_pluck')) |
|
333 | 333 | { |
334 | 334 | /** |
335 | 335 | * Pluck an array of values from an array. |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | -if ( ! function_exists('array_pull')) |
|
369 | +if (!function_exists('array_pull')) |
|
370 | 370 | { |
371 | 371 | /** |
372 | 372 | * Get a value from the array, and remove it. |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | -if ( ! function_exists('array_set')) |
|
389 | +if (!function_exists('array_set')) |
|
390 | 390 | { |
391 | 391 | /** |
392 | 392 | * Set an array item to a given value using "dot" notation. |
@@ -411,12 +411,12 @@ discard block |
||
411 | 411 | // If the key doesn't exist at this depth, we will just create an empty array |
412 | 412 | // to hold the next value, allowing us to create the arrays to hold final |
413 | 413 | // values at the correct depth. Then we'll keep digging into the array. |
414 | - if ( ! isset($array[$key]) || ! is_array($array[$key])) |
|
414 | + if (!isset($array[$key]) || !is_array($array[$key])) |
|
415 | 415 | { |
416 | 416 | $array[$key] = array(); |
417 | 417 | } |
418 | 418 | |
419 | - $array =& $array[$key]; |
|
419 | + $array = & $array[$key]; |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $array[array_shift($keys)] = $value; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | -if ( ! function_exists('array_where')) |
|
428 | +if (!function_exists('array_where')) |
|
429 | 429 | { |
430 | 430 | /** |
431 | 431 | * Filter the array using the given Closure. |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | -if ( ! function_exists('camel_case')) |
|
450 | +if (!function_exists('camel_case')) |
|
451 | 451 | { |
452 | 452 | /** |
453 | 453 | * Convert a value to camel case. |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
471 | -if ( ! function_exists('class_basename')) |
|
471 | +if (!function_exists('class_basename')) |
|
472 | 472 | { |
473 | 473 | /** |
474 | 474 | * Get the class "basename" of the given object / class. |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | -if ( ! function_exists('class_uses_recursive')) |
|
487 | +if (!function_exists('class_uses_recursive')) |
|
488 | 488 | { |
489 | 489 | /** |
490 | 490 | * Returns all traits used by a class, it's subclasses and trait of their traits |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | -if ( ! function_exists('data_get')) |
|
508 | +if (!function_exists('data_get')) |
|
509 | 509 | { |
510 | 510 | /** |
511 | 511 | * Get an item from an array or object using "dot" notation. |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | { |
524 | 524 | if (is_array($target)) |
525 | 525 | { |
526 | - if ( ! array_key_exists($segment, $target)) |
|
526 | + if (!array_key_exists($segment, $target)) |
|
527 | 527 | { |
528 | 528 | return value($default); |
529 | 529 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | } |
533 | 533 | elseif ($target instanceof ArrayAccess) |
534 | 534 | { |
535 | - if ( ! isset($target[$segment])) |
|
535 | + if (!isset($target[$segment])) |
|
536 | 536 | { |
537 | 537 | return value($default); |
538 | 538 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | } |
542 | 542 | elseif (is_object($target)) |
543 | 543 | { |
544 | - if ( ! isset($target->{$segment})) |
|
544 | + if (!isset($target->{$segment})) |
|
545 | 545 | { |
546 | 546 | return value($default); |
547 | 547 | } |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | -if ( ! function_exists('e')) |
|
561 | +if (!function_exists('e')) |
|
562 | 562 | { |
563 | 563 | /** |
564 | 564 | * Escape HTML entities in a string. |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | } |
573 | 573 | } |
574 | 574 | |
575 | -if ( ! function_exists('ends_with')) |
|
575 | +if (!function_exists('ends_with')) |
|
576 | 576 | { |
577 | 577 | /** |
578 | 578 | * Determine if a given string ends with a given substring. |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | -if ( ! function_exists('head')) |
|
595 | +if (!function_exists('head')) |
|
596 | 596 | { |
597 | 597 | /** |
598 | 598 | * Get the first element of an array. Useful for method chaining. |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
609 | -if ( ! function_exists('last')) |
|
609 | +if (!function_exists('last')) |
|
610 | 610 | { |
611 | 611 | /** |
612 | 612 | * Get the last element from an array. |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | } |
621 | 621 | } |
622 | 622 | |
623 | -if ( ! function_exists('object_get')) |
|
623 | +if (!function_exists('object_get')) |
|
624 | 624 | { |
625 | 625 | /** |
626 | 626 | * Get an item from an object using "dot" notation. |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | |
637 | 637 | foreach (explode('.', $key) as $segment) |
638 | 638 | { |
639 | - if ( ! is_object($object) || ! isset($object->{$segment})) |
|
639 | + if (!is_object($object) || !isset($object->{$segment})) |
|
640 | 640 | { |
641 | 641 | return value($default); |
642 | 642 | } |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | -if ( ! function_exists('preg_replace_sub')) |
|
651 | +if (!function_exists('preg_replace_sub')) |
|
652 | 652 | { |
653 | 653 | /** |
654 | 654 | * Replace a given pattern with each value in the array in sequentially. |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | } |
669 | 669 | } |
670 | 670 | |
671 | -if ( ! function_exists('snake_case')) |
|
671 | +if (!function_exists('snake_case')) |
|
672 | 672 | { |
673 | 673 | /** |
674 | 674 | * Convert a string to snake case. |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | return $snakeCache[$key]; |
688 | 688 | } |
689 | 689 | |
690 | - if ( ! ctype_lower($value)) |
|
690 | + if (!ctype_lower($value)) |
|
691 | 691 | { |
692 | 692 | $value = strtolower(preg_replace('/(.)(?=[A-Z])/', '$1'.$delimiter, $value)); |
693 | 693 | } |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | } |
697 | 697 | } |
698 | 698 | |
699 | -if ( ! function_exists('starts_with')) |
|
699 | +if (!function_exists('starts_with')) |
|
700 | 700 | { |
701 | 701 | /** |
702 | 702 | * Determine if a given string starts with a given substring. |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | } |
717 | 717 | } |
718 | 718 | |
719 | -if ( ! function_exists('str_contains')) |
|
719 | +if (!function_exists('str_contains')) |
|
720 | 720 | { |
721 | 721 | /** |
722 | 722 | * Determine if a given string contains a given substring. |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | } |
737 | 737 | } |
738 | 738 | |
739 | -if ( ! function_exists('str_finish')) |
|
739 | +if (!function_exists('str_finish')) |
|
740 | 740 | { |
741 | 741 | /** |
742 | 742 | * Cap a string with a single instance of a given value. |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | } |
754 | 754 | } |
755 | 755 | |
756 | -if ( ! function_exists('str_is')) |
|
756 | +if (!function_exists('str_is')) |
|
757 | 757 | { |
758 | 758 | /** |
759 | 759 | * Determine if a given string matches a given pattern. |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | } |
778 | 778 | } |
779 | 779 | |
780 | -if ( ! function_exists('str_limit')) |
|
780 | +if (!function_exists('str_limit')) |
|
781 | 781 | { |
782 | 782 | /** |
783 | 783 | * Limit the number of characters in a string. |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | } |
796 | 796 | } |
797 | 797 | |
798 | -if ( ! function_exists('str_random')) |
|
798 | +if (!function_exists('str_random')) |
|
799 | 799 | { |
800 | 800 | /** |
801 | 801 | * Generate a more truly "random" alpha-numeric string. |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | */ |
808 | 808 | function str_random($length = 16) |
809 | 809 | { |
810 | - if ( ! function_exists('openssl_random_pseudo_bytes')) |
|
810 | + if (!function_exists('openssl_random_pseudo_bytes')) |
|
811 | 811 | { |
812 | 812 | throw new RuntimeException('OpenSSL extension is required.'); |
813 | 813 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | } |
824 | 824 | } |
825 | 825 | |
826 | -if ( ! function_exists('str_replace_array')) |
|
826 | +if (!function_exists('str_replace_array')) |
|
827 | 827 | { |
828 | 828 | /** |
829 | 829 | * Replace a given value in the string sequentially with an array. |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
847 | -if ( ! function_exists('studly_case')) |
|
847 | +if (!function_exists('studly_case')) |
|
848 | 848 | { |
849 | 849 | /** |
850 | 850 | * Convert a value to studly caps case. |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | } |
869 | 869 | } |
870 | 870 | |
871 | -if ( ! function_exists('trait_uses_recursive')) |
|
871 | +if (!function_exists('trait_uses_recursive')) |
|
872 | 872 | { |
873 | 873 | /** |
874 | 874 | * Returns all traits used by a trait and its traits |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | } |
890 | 890 | } |
891 | 891 | |
892 | -if ( ! function_exists('value')) |
|
892 | +if (!function_exists('value')) |
|
893 | 893 | { |
894 | 894 | /** |
895 | 895 | * Return the default value of the given value. |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | } |
904 | 904 | } |
905 | 905 | |
906 | -if ( ! function_exists('with')) |
|
906 | +if (!function_exists('with')) |
|
907 | 907 | { |
908 | 908 | /** |
909 | 909 | * Return the given object. Useful for chaining. |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | /** |
921 | 921 | * Helper functions for the helper functions, that can still be used standalone |
922 | 922 | */ |
923 | -if ( ! function_exists('studly')) |
|
923 | +if (!function_exists('studly')) |
|
924 | 924 | { |
925 | 925 | /** |
926 | 926 | * Convert a value to studly caps case. |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | } |
945 | 945 | } |
946 | 946 | |
947 | -if ( ! function_exists('get')) |
|
947 | +if (!function_exists('get')) |
|
948 | 948 | { |
949 | 949 | /** |
950 | 950 | * Get an item from an array using "dot" notation. |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | |
963 | 963 | foreach (explode('.', $key) as $segment) |
964 | 964 | { |
965 | - if ( ! is_array($array) || ! array_key_exists($segment, $array)) |
|
965 | + if (!is_array($array) || !array_key_exists($segment, $array)) |
|
966 | 966 | { |
967 | 967 | return value($default); |
968 | 968 | } |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | } |
975 | 975 | } |
976 | 976 | |
977 | -if ( ! function_exists('set')) |
|
977 | +if (!function_exists('set')) |
|
978 | 978 | { |
979 | 979 | /** |
980 | 980 | * Set an array item to a given value using "dot" notation. |
@@ -999,12 +999,12 @@ discard block |
||
999 | 999 | // If the key doesn't exist at this depth, we will just create an empty array |
1000 | 1000 | // to hold the next value, allowing us to create the arrays to hold final |
1001 | 1001 | // values at the correct depth. Then we'll keep digging into the array. |
1002 | - if ( ! isset($array[$key]) || ! is_array($array[$key])) |
|
1002 | + if (!isset($array[$key]) || !is_array($array[$key])) |
|
1003 | 1003 | { |
1004 | 1004 | $array[$key] = array(); |
1005 | 1005 | } |
1006 | 1006 | |
1007 | - $array =& $array[$key]; |
|
1007 | + $array = & $array[$key]; |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | $array[array_shift($keys)] = $value; |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | |
1016 | -if ( ! function_exists('dot')) |
|
1016 | +if (!function_exists('dot')) |
|
1017 | 1017 | { |
1018 | 1018 | /** |
1019 | 1019 | * Flatten a multi-dimensional associative array with dots. |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | |
1045 | -if ( ! function_exists('first')) |
|
1045 | +if (!function_exists('first')) |
|
1046 | 1046 | { |
1047 | 1047 | /** |
1048 | 1048 | * Return the first element in an array passing a given truth test. |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | } |
1064 | 1064 | } |
1065 | 1065 | |
1066 | -if ( ! function_exists('forget')) |
|
1066 | +if (!function_exists('forget')) |
|
1067 | 1067 | { |
1068 | 1068 | /** |
1069 | 1069 | * Remove one or many array items from a given array using "dot" notation. |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | */ |
1075 | 1075 | function forget(&$array, $keys) |
1076 | 1076 | { |
1077 | - $original =& $array; |
|
1077 | + $original = & $array; |
|
1078 | 1078 | |
1079 | 1079 | foreach ((array) $keys as $key) |
1080 | 1080 | { |
@@ -1086,14 +1086,14 @@ discard block |
||
1086 | 1086 | |
1087 | 1087 | if (isset($array[$part]) && is_array($array[$part])) |
1088 | 1088 | { |
1089 | - $array =& $array[$part]; |
|
1089 | + $array = & $array[$part]; |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | unset($array[array_shift($parts)]); |
1094 | 1094 | |
1095 | 1095 | // clean up after each pass |
1096 | - $array =& $original; |
|
1096 | + $array = & $original; |
|
1097 | 1097 | } |
1098 | 1098 | } |
1099 | 1099 | } |
1100 | 1100 | \ No newline at end of file |
@@ -109,8 +109,7 @@ discard block |
||
109 | 109 | if (is_array($value)) |
110 | 110 | { |
111 | 111 | $results = array_merge($results, dot($value, $prepend.$key.'.')); |
112 | - } |
|
113 | - else |
|
112 | + } else |
|
114 | 113 | { |
115 | 114 | $results[$prepend.$key] = $value; |
116 | 115 | } |
@@ -179,7 +178,9 @@ discard block |
||
179 | 178 | { |
180 | 179 | foreach ($array as $key => $value) |
181 | 180 | { |
182 | - if (call_user_func($callback, $key, $value)) return $value; |
|
181 | + if (call_user_func($callback, $key, $value)) { |
|
182 | + return $value; |
|
183 | + } |
|
183 | 184 | } |
184 | 185 | |
185 | 186 | return value($default); |
@@ -267,9 +268,13 @@ discard block |
||
267 | 268 | */ |
268 | 269 | function array_get($array, $key, $default = null) |
269 | 270 | { |
270 | - if (is_null($key)) return $array; |
|
271 | + if (is_null($key)) { |
|
272 | + return $array; |
|
273 | + } |
|
271 | 274 | |
272 | - if (isset($array[$key])) return $array[$key]; |
|
275 | + if (isset($array[$key])) { |
|
276 | + return $array[$key]; |
|
277 | + } |
|
273 | 278 | |
274 | 279 | foreach (explode('.', $key) as $segment) |
275 | 280 | { |
@@ -296,9 +301,13 @@ discard block |
||
296 | 301 | */ |
297 | 302 | function array_has($array, $key) |
298 | 303 | { |
299 | - if (empty($array) || is_null($key)) return false; |
|
304 | + if (empty($array) || is_null($key)) { |
|
305 | + return false; |
|
306 | + } |
|
300 | 307 | |
301 | - if (array_key_exists($key, $array)) return true; |
|
308 | + if (array_key_exists($key, $array)) { |
|
309 | + return true; |
|
310 | + } |
|
302 | 311 | |
303 | 312 | foreach (explode('.', $key) as $segment) |
304 | 313 | { |
@@ -353,8 +362,7 @@ discard block |
||
353 | 362 | if (is_null($key)) |
354 | 363 | { |
355 | 364 | $results[] = $itemValue; |
356 | - } |
|
357 | - else |
|
365 | + } else |
|
358 | 366 | { |
359 | 367 | $itemKey = data_get($item, $key); |
360 | 368 | |
@@ -400,7 +408,9 @@ discard block |
||
400 | 408 | */ |
401 | 409 | function array_set(&$array, $key, $value) |
402 | 410 | { |
403 | - if (is_null($key)) return $array = $value; |
|
411 | + if (is_null($key)) { |
|
412 | + return $array = $value; |
|
413 | + } |
|
404 | 414 | |
405 | 415 | $keys = explode('.', $key); |
406 | 416 | |
@@ -440,7 +450,9 @@ discard block |
||
440 | 450 | |
441 | 451 | foreach ($array as $key => $value) |
442 | 452 | { |
443 | - if (call_user_func($callback, $key, $value)) $filtered[$key] = $value; |
|
453 | + if (call_user_func($callback, $key, $value)) { |
|
454 | + $filtered[$key] = $value; |
|
455 | + } |
|
444 | 456 | } |
445 | 457 | |
446 | 458 | return $filtered; |
@@ -517,7 +529,9 @@ discard block |
||
517 | 529 | */ |
518 | 530 | function data_get($target, $key, $default = null) |
519 | 531 | { |
520 | - if (is_null($key)) return $target; |
|
532 | + if (is_null($key)) { |
|
533 | + return $target; |
|
534 | + } |
|
521 | 535 | |
522 | 536 | foreach (explode('.', $key) as $segment) |
523 | 537 | { |
@@ -529,8 +543,7 @@ discard block |
||
529 | 543 | } |
530 | 544 | |
531 | 545 | $target = $target[$segment]; |
532 | - } |
|
533 | - elseif ($target instanceof ArrayAccess) |
|
546 | + } elseif ($target instanceof ArrayAccess) |
|
534 | 547 | { |
535 | 548 | if ( ! isset($target[$segment])) |
536 | 549 | { |
@@ -538,8 +551,7 @@ discard block |
||
538 | 551 | } |
539 | 552 | |
540 | 553 | $target = $target[$segment]; |
541 | - } |
|
542 | - elseif (is_object($target)) |
|
554 | + } elseif (is_object($target)) |
|
543 | 555 | { |
544 | 556 | if ( ! isset($target->{$segment})) |
545 | 557 | { |
@@ -547,8 +559,7 @@ discard block |
||
547 | 559 | } |
548 | 560 | |
549 | 561 | $target = $target->{$segment}; |
550 | - } |
|
551 | - else |
|
562 | + } else |
|
552 | 563 | { |
553 | 564 | return value($default); |
554 | 565 | } |
@@ -585,7 +596,9 @@ discard block |
||
585 | 596 | { |
586 | 597 | foreach ((array) $needles as $needle) |
587 | 598 | { |
588 | - if ((string) $needle === substr($haystack, -strlen($needle))) return true; |
|
599 | + if ((string) $needle === substr($haystack, -strlen($needle))) { |
|
600 | + return true; |
|
601 | + } |
|
589 | 602 | } |
590 | 603 | |
591 | 604 | return false; |
@@ -632,7 +645,9 @@ discard block |
||
632 | 645 | */ |
633 | 646 | function object_get($object, $key, $default = null) |
634 | 647 | { |
635 | - if (is_null($key) || trim($key) == '') return $object; |
|
648 | + if (is_null($key) || trim($key) == '') { |
|
649 | + return $object; |
|
650 | + } |
|
636 | 651 | |
637 | 652 | foreach (explode('.', $key) as $segment) |
638 | 653 | { |
@@ -709,7 +724,9 @@ discard block |
||
709 | 724 | { |
710 | 725 | foreach ((array) $needles as $needle) |
711 | 726 | { |
712 | - if ($needle != '' && strpos($haystack, $needle) === 0) return true; |
|
727 | + if ($needle != '' && strpos($haystack, $needle) === 0) { |
|
728 | + return true; |
|
729 | + } |
|
713 | 730 | } |
714 | 731 | |
715 | 732 | return false; |
@@ -729,7 +746,9 @@ discard block |
||
729 | 746 | { |
730 | 747 | foreach ((array) $needles as $needle) |
731 | 748 | { |
732 | - if ($needle != '' && strpos($haystack, $needle) !== false) return true; |
|
749 | + if ($needle != '' && strpos($haystack, $needle) !== false) { |
|
750 | + return true; |
|
751 | + } |
|
733 | 752 | } |
734 | 753 | |
735 | 754 | return false; |
@@ -764,7 +783,9 @@ discard block |
||
764 | 783 | */ |
765 | 784 | function str_is($pattern, $value) |
766 | 785 | { |
767 | - if ($pattern == $value) return true; |
|
786 | + if ($pattern == $value) { |
|
787 | + return true; |
|
788 | + } |
|
768 | 789 | |
769 | 790 | $pattern = preg_quote($pattern, '#'); |
770 | 791 | |
@@ -789,7 +810,9 @@ discard block |
||
789 | 810 | */ |
790 | 811 | function str_limit($value, $limit = 100, $end = '...') |
791 | 812 | { |
792 | - if (mb_strlen($value) <= $limit) return $value; |
|
813 | + if (mb_strlen($value) <= $limit) { |
|
814 | + return $value; |
|
815 | + } |
|
793 | 816 | |
794 | 817 | return rtrim(mb_substr($value, 0, $limit, 'UTF-8')).$end; |
795 | 818 | } |
@@ -956,9 +979,13 @@ discard block |
||
956 | 979 | */ |
957 | 980 | function get($array, $key, $default = null) |
958 | 981 | { |
959 | - if (is_null($key)) return $array; |
|
982 | + if (is_null($key)) { |
|
983 | + return $array; |
|
984 | + } |
|
960 | 985 | |
961 | - if (isset($array[$key])) return $array[$key]; |
|
986 | + if (isset($array[$key])) { |
|
987 | + return $array[$key]; |
|
988 | + } |
|
962 | 989 | |
963 | 990 | foreach (explode('.', $key) as $segment) |
964 | 991 | { |
@@ -988,7 +1015,9 @@ discard block |
||
988 | 1015 | */ |
989 | 1016 | function set(&$array, $key, $value) |
990 | 1017 | { |
991 | - if (is_null($key)) return $array = $value; |
|
1018 | + if (is_null($key)) { |
|
1019 | + return $array = $value; |
|
1020 | + } |
|
992 | 1021 | |
993 | 1022 | $keys = explode('.', $key); |
994 | 1023 | |
@@ -1031,8 +1060,7 @@ discard block |
||
1031 | 1060 | if (is_array($value)) |
1032 | 1061 | { |
1033 | 1062 | $results = array_merge($results, dot($value, $prepend.$key.'.')); |
1034 | - } |
|
1035 | - else |
|
1063 | + } else |
|
1036 | 1064 | { |
1037 | 1065 | $results[$prepend.$key] = $value; |
1038 | 1066 | } |
@@ -1056,7 +1084,9 @@ discard block |
||
1056 | 1084 | { |
1057 | 1085 | foreach ($array as $key => $value) |
1058 | 1086 | { |
1059 | - if (call_user_func($callback, $key, $value)) return $value; |
|
1087 | + if (call_user_func($callback, $key, $value)) { |
|
1088 | + return $value; |
|
1089 | + } |
|
1060 | 1090 | } |
1061 | 1091 | |
1062 | 1092 | return value($default); |