Overview

Namespaces

  • None
  • PHP

Functions

  • action
  • app
  • app_path
  • append_config
  • array_add
  • array_build
  • array_divide
  • array_dot
  • array_except
  • array_fetch
  • array_first
  • array_flatten
  • array_forget
  • array_get
  • array_last
  • array_only
  • array_pluck
  • array_pull
  • array_set
  • array_sort
  • array_where
  • asset
  • base_path
  • camel_case
  • class_basename
  • csrf_token
  • data_get
  • dd
  • e
  • ends_with
  • head
  • last
  • link_to
  • link_to_action
  • link_to_asset
  • link_to_route
  • object_get
  • preg_replace_sub
  • public_path
  • route
  • secure_asset
  • secure_url
  • snake_case
  • starts_with
  • storage_path
  • str_contains
  • str_finish
  • str_is
  • str_limit
  • str_plural
  • str_random
  • str_replace_array
  • str_singular
  • studly_case
  • trans
  • trans_choice
  • url
  • value
  • with
  • Overview
  • Namespace
  • Function
  • Tree
   1: <?php
   2: 
   3: if ( ! function_exists('action'))
   4: {
   5:     /**
   6:      * Generate a URL to a controller action.
   7:      *
   8:      * @param  string  $name
   9:      * @param  array   $parameters
  10:      * @return string
  11:      */
  12:     function action($name, $parameters = array())
  13:     {
  14:         return app('url')->action($name, $parameters);
  15:     }
  16: }
  17: 
  18: if ( ! function_exists('app'))
  19: {
  20:     /**
  21:      * Get the root Facade application instance.
  22:      *
  23:      * @param  string  $make
  24:      * @return mixed
  25:      */
  26:     function app($make = null)
  27:     {
  28:         if ( ! is_null($make))
  29:         {
  30:             return app()->make($make);
  31:         }
  32: 
  33:         return Illuminate\Support\Facades\Facade::getFacadeApplication();
  34:     }
  35: }
  36: 
  37: if ( ! function_exists('app_path'))
  38: {
  39:     /**
  40:      * Get the path to the application folder.
  41:      *
  42:      * @param   string  $path
  43:      * @return  string
  44:      */
  45:     function app_path($path = '')
  46:     {
  47:         return app('path').($path ? '/'.$path : $path);
  48:     }
  49: }
  50: 
  51: if ( ! function_exists('append_config'))
  52: {
  53:     /**
  54:      * Assign high numeric IDs to a config item to force appending.
  55:      *
  56:      * @param  array  $array
  57:      * @return array
  58:      */
  59:     function append_config(array $array)
  60:     {
  61:         $start = 9999;
  62: 
  63:         foreach ($array as $key => $value)
  64:         {
  65:             if (is_numeric($key))
  66:             {
  67:                 $start++;
  68: 
  69:                 $array[$start] = array_pull($array, $key);
  70:             }
  71:         }
  72: 
  73:         return $array;
  74:     }
  75: }
  76: 
  77: if ( ! function_exists('array_add'))
  78: {
  79:     /**
  80:      * Add an element to an array using "dot" notation if it doesn't exist.
  81:      *
  82:      * @param  array   $array
  83:      * @param  string  $key
  84:      * @param  mixed   $value
  85:      * @return array
  86:      */
  87:     function array_add($array, $key, $value)
  88:     {
  89:         if (is_null(array_get($array, $key)))
  90:         {
  91:             array_set($array, $key, $value);
  92:         }
  93: 
  94:         return $array;
  95:     }
  96: }
  97: 
  98: if ( ! function_exists('array_build'))
  99: {
 100:     /**
 101:      * Build a new array using a callback.
 102:      *
 103:      * @param  array  $array
 104:      * @param  \Closure  $callback
 105:      * @return array
 106:      */
 107:     function array_build($array, Closure $callback)
 108:     {
 109:         $results = array();
 110: 
 111:         foreach ($array as $key => $value)
 112:         {
 113:             list($innerKey, $innerValue) = call_user_func($callback, $key, $value);
 114: 
 115:             $results[$innerKey] = $innerValue;
 116:         }
 117: 
 118:         return $results;
 119:     }
 120: }
 121: 
 122: if ( ! function_exists('array_divide'))
 123: {
 124:     /**
 125:      * Divide an array into two arrays. One with keys and the other with values.
 126:      *
 127:      * @param  array  $array
 128:      * @return array
 129:      */
 130:     function array_divide($array)
 131:     {
 132:         return array(array_keys($array), array_values($array));
 133:     }
 134: }
 135: 
 136: if ( ! function_exists('array_dot'))
 137: {
 138:     /**
 139:      * Flatten a multi-dimensional associative array with dots.
 140:      *
 141:      * @param  array   $array
 142:      * @param  string  $prepend
 143:      * @return array
 144:      */
 145:     function array_dot($array, $prepend = '')
 146:     {
 147:         $results = array();
 148: 
 149:         foreach ($array as $key => $value)
 150:         {
 151:             if (is_array($value))
 152:             {
 153:                 $results = array_merge($results, array_dot($value, $prepend.$key.'.'));
 154:             }
 155:             else
 156:             {
 157:                 $results[$prepend.$key] = $value;
 158:             }
 159:         }
 160: 
 161:         return $results;
 162:     }
 163: }
 164: 
 165: if ( ! function_exists('array_except'))
 166: {
 167:     /**
 168:      * Get all of the given array except for a specified array of items.
 169:      *
 170:      * @param  array  $array
 171:      * @param  array  $keys
 172:      * @return array
 173:      */
 174:     function array_except($array, $keys)
 175:     {
 176:         return array_diff_key($array, array_flip((array) $keys));
 177:     }
 178: }
 179: 
 180: if ( ! function_exists('array_fetch'))
 181: {
 182:     /**
 183:      * Fetch a flattened array of a nested array element.
 184:      *
 185:      * @param  array   $array
 186:      * @param  string  $key
 187:      * @return array
 188:      */
 189:     function array_fetch($array, $key)
 190:     {
 191:         foreach (explode('.', $key) as $segment)
 192:         {
 193:             $results = array();
 194: 
 195:             foreach ($array as $value)
 196:             {
 197:                 $value = (array) $value;
 198: 
 199:                 $results[] = $value[$segment];
 200:             }
 201: 
 202:             $array = array_values($results);
 203:         }
 204: 
 205:         return array_values($results);
 206:     }
 207: }
 208: 
 209: if ( ! function_exists('array_first'))
 210: {
 211:     /**
 212:      * Return the first element in an array passing a given truth test.
 213:      *
 214:      * @param  array    $array
 215:      * @param  Closure  $callback
 216:      * @param  mixed    $default
 217:      * @return mixed
 218:      */
 219:     function array_first($array, $callback, $default = null)
 220:     {
 221:         foreach ($array as $key => $value)
 222:         {
 223:             if (call_user_func($callback, $key, $value)) return $value;
 224:         }
 225: 
 226:         return value($default);
 227:     }
 228: }
 229: 
 230: if ( ! function_exists('array_last'))
 231: {
 232:     /**
 233:      * Return the last element in an array passing a given truth test.
 234:      *
 235:      * @param  array    $array
 236:      * @param  Closure  $callback
 237:      * @param  mixed    $default
 238:      * @return mixed
 239:      */
 240:     function array_last($array, $callback, $default = null)
 241:     {
 242:         return array_first(array_reverse($array), $callback, $default);
 243:     }
 244: }
 245: 
 246: if ( ! function_exists('array_flatten'))
 247: {
 248:     /**
 249:      * Flatten a multi-dimensional array into a single level.
 250:      *
 251:      * @param  array  $array
 252:      * @return array
 253:      */
 254:     function array_flatten($array)
 255:     {
 256:         $return = array();
 257: 
 258:         array_walk_recursive($array, function($x) use (&$return) { $return[] = $x; });
 259: 
 260:         return $return;
 261:     }
 262: }
 263: 
 264: if ( ! function_exists('array_forget'))
 265: {
 266:     /**
 267:      * Remove an array item from a given array using "dot" notation.
 268:      *
 269:      * @param  array   $array
 270:      * @param  string  $key
 271:      * @return void
 272:      */
 273:     function array_forget(&$array, $key)
 274:     {
 275:         $keys = explode('.', $key);
 276: 
 277:         while (count($keys) > 1)
 278:         {
 279:             $key = array_shift($keys);
 280: 
 281:             if ( ! isset($array[$key]) || ! is_array($array[$key]))
 282:             {
 283:                 return;
 284:             }
 285: 
 286:             $array =& $array[$key];
 287:         }
 288: 
 289:         unset($array[array_shift($keys)]);
 290:     }
 291: }
 292: 
 293: if ( ! function_exists('array_get'))
 294: {
 295:     /**
 296:      * Get an item from an array using "dot" notation.
 297:      *
 298:      * @param  array   $array
 299:      * @param  string  $key
 300:      * @param  mixed   $default
 301:      * @return mixed
 302:      */
 303:     function array_get($array, $key, $default = null)
 304:     {
 305:         if (is_null($key)) return $array;
 306: 
 307:         if (isset($array[$key])) return $array[$key];
 308: 
 309:         foreach (explode('.', $key) as $segment)
 310:         {
 311:             if ( ! is_array($array) || ! array_key_exists($segment, $array))
 312:             {
 313:                 return value($default);
 314:             }
 315: 
 316:             $array = $array[$segment];
 317:         }
 318: 
 319:         return $array;
 320:     }
 321: }
 322: 
 323: if ( ! function_exists('array_only'))
 324: {
 325:     /**
 326:      * Get a subset of the items from the given array.
 327:      *
 328:      * @param  array  $array
 329:      * @param  array  $keys
 330:      * @return array
 331:      */
 332:     function array_only($array, $keys)
 333:     {
 334:         return array_intersect_key($array, array_flip((array) $keys));
 335:     }
 336: }
 337: 
 338: if ( ! function_exists('array_pluck'))
 339: {
 340:     /**
 341:      * Pluck an array of values from an array.
 342:      *
 343:      * @param  array   $array
 344:      * @param  string  $value
 345:      * @param  string  $key
 346:      * @return array
 347:      */
 348:     function array_pluck($array, $value, $key = null)
 349:     {
 350:         $results = array();
 351: 
 352:         foreach ($array as $item)
 353:         {
 354:             $itemValue = is_object($item) ? $item->{$value} : $item[$value];
 355: 
 356:             // If the key is "null", we will just append the value to the array and keep
 357:             // looping. Otherwise we will key the array using the value of the key we
 358:             // received from the developer. Then we'll return the final array form.
 359:             if (is_null($key))
 360:             {
 361:                 $results[] = $itemValue;
 362:             }
 363:             else
 364:             {
 365:                 $itemKey = is_object($item) ? $item->{$key} : $item[$key];
 366: 
 367:                 $results[$itemKey] = $itemValue;
 368:             }
 369:         }
 370: 
 371:         return $results;
 372:     }
 373: }
 374: 
 375: if ( ! function_exists('array_pull'))
 376: {
 377:     /**
 378:      * Get a value from the array, and remove it.
 379:      *
 380:      * @param  array   $array
 381:      * @param  string  $key
 382:      * @param  mixed   $default
 383:      * @return mixed
 384:      */
 385:     function array_pull(&$array, $key, $default = null)
 386:     {
 387:         $value = array_get($array, $key, $default);
 388: 
 389:         array_forget($array, $key);
 390: 
 391:         return $value;
 392:     }
 393: }
 394: 
 395: if ( ! function_exists('array_set'))
 396: {
 397:     /**
 398:      * Set an array item to a given value using "dot" notation.
 399:      *
 400:      * If no key is given to the method, the entire array will be replaced.
 401:      *
 402:      * @param  array   $array
 403:      * @param  string  $key
 404:      * @param  mixed   $value
 405:      * @return array
 406:      */
 407:     function array_set(&$array, $key, $value)
 408:     {
 409:         if (is_null($key)) return $array = $value;
 410: 
 411:         $keys = explode('.', $key);
 412: 
 413:         while (count($keys) > 1)
 414:         {
 415:             $key = array_shift($keys);
 416: 
 417:             // If the key doesn't exist at this depth, we will just create an empty array
 418:             // to hold the next value, allowing us to create the arrays to hold final
 419:             // values at the correct depth. Then we'll keep digging into the array.
 420:             if ( ! isset($array[$key]) || ! is_array($array[$key]))
 421:             {
 422:                 $array[$key] = array();
 423:             }
 424: 
 425:             $array =& $array[$key];
 426:         }
 427: 
 428:         $array[array_shift($keys)] = $value;
 429: 
 430:         return $array;
 431:     }
 432: }
 433: 
 434: if ( ! function_exists('array_sort'))
 435: {
 436:     /**
 437:      * Sort the array using the given Closure.
 438:      *
 439:      * @param  array  $array
 440:      * @param  \Closure  $callback
 441:      * @return array
 442:      */
 443:     function array_sort($array, Closure $callback)
 444:     {
 445:         return Illuminate\Support\Collection::make($array)->sortBy($callback)->all();
 446:     }
 447: }
 448: 
 449: if ( ! function_exists('array_where'))
 450: {
 451:     /**
 452:      * Filter the array using the given Closure.
 453:      *
 454:      * @param  array  $array
 455:      * @param  \Closure  $callback
 456:      * @return array
 457:      */
 458:     function array_where($array, Closure $callback)
 459:     {
 460:         $filtered = array();
 461: 
 462:         foreach ($array as $key => $value)
 463:         {
 464:             if (call_user_func($callback, $key, $value)) $filtered[$key] = $value;
 465:         }
 466: 
 467:         return $filtered;
 468:     }
 469: }
 470: 
 471: if ( ! function_exists('asset'))
 472: {
 473:     /**
 474:      * Generate an asset path for the application.
 475:      *
 476:      * @param  string  $path
 477:      * @param  bool    $secure
 478:      * @return string
 479:      */
 480:     function asset($path, $secure = null)
 481:     {
 482:         return app('url')->asset($path, $secure);
 483:     }
 484: }
 485: 
 486: if ( ! function_exists('base_path'))
 487: {
 488:     /**
 489:      * Get the path to the base of the install.
 490:      *
 491:      * @param  string  $path
 492:      * @return string
 493:      */
 494:     function base_path($path = '')
 495:     {
 496:         return app()->make('path.base').($path ? '/'.$path : $path);
 497:     }
 498: }
 499: 
 500: if ( ! function_exists('camel_case'))
 501: {
 502:     /**
 503:      * Convert a value to camel case.
 504:      *
 505:      * @param  string  $value
 506:      * @return string
 507:      */
 508:     function camel_case($value)
 509:     {
 510:         return Illuminate\Support\Str::camel($value);
 511:     }
 512: }
 513: 
 514: if ( ! function_exists('class_basename'))
 515: {
 516:     /**
 517:      * Get the class "basename" of the given object / class.
 518:      *
 519:      * @param  string|object  $class
 520:      * @return string
 521:      */
 522:     function class_basename($class)
 523:     {
 524:         $class = is_object($class) ? get_class($class) : $class;
 525: 
 526:         return basename(str_replace('\\', '/', $class));
 527:     }
 528: }
 529: 
 530: if ( ! function_exists('csrf_token'))
 531: {
 532:     /**
 533:      * Get the CSRF token value.
 534:      *
 535:      * @return string
 536:      *
 537:      * @throws RuntimeException
 538:      */
 539:     function csrf_token()
 540:     {
 541:         $session = app('session');
 542: 
 543:         if (isset($session))
 544:         {
 545:             return $session->getToken();
 546:         }
 547:         else
 548:         {
 549:             throw new RuntimeException("Application session store not set.");
 550:         }
 551:     }
 552: }
 553: 
 554: if ( ! function_exists('data_get'))
 555: {
 556:     /**
 557:      * Get an item from an array or object using "dot" notation.
 558:      *
 559:      * @param  mixed   $target
 560:      * @param  string  $key
 561:      * @param  mixed   $default
 562:      * @return mixed
 563:      */
 564:     function data_get($target, $key, $default = null)
 565:     {
 566:         if (is_null($key)) return $target;
 567: 
 568:         foreach (explode('.', $key) as $segment)
 569:         {
 570:             if (is_array($target))
 571:             {
 572:                 if ( ! array_key_exists($segment, $target))
 573:                 {
 574:                     return value($default);
 575:                 }
 576: 
 577:                 $target = $target[$segment];
 578:             }
 579:             elseif (is_object($target))
 580:             {
 581:                 if ( ! isset($target->{$segment}))
 582:                 {
 583:                     return value($default);
 584:                 }
 585: 
 586:                 $target = $target->{$segment};
 587:             }
 588:             else
 589:             {
 590:                 return value($default);
 591:             }
 592:         }
 593: 
 594:         return $target;
 595:     }
 596: }
 597: 
 598: if ( ! function_exists('dd'))
 599: {
 600:     /**
 601:      * Dump the passed variables and end the script.
 602:      *
 603:      * @param  dynamic  mixed
 604:      * @return void
 605:      */
 606:     function dd()
 607:     {
 608:         array_map(function($x) { var_dump($x); }, func_get_args()); die;
 609:     }
 610: }
 611: 
 612: if ( ! function_exists('e'))
 613: {
 614:     /**
 615:      * Escape HTML entities in a string.
 616:      *
 617:      * @param  string  $value
 618:      * @return string
 619:      */
 620:     function e($value)
 621:     {
 622:         return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
 623:     }
 624: }
 625: 
 626: if ( ! function_exists('ends_with'))
 627: {
 628:     /**
 629:      * Determine if a given string ends with a given substring.
 630:      *
 631:      * @param string  $haystack
 632:      * @param string|array  $needle
 633:      * @return bool
 634:      */
 635:     function ends_with($haystack, $needle)
 636:     {
 637:         return Illuminate\Support\Str::endsWith($haystack, $needle);
 638:     }
 639: }
 640: 
 641: if ( ! function_exists('head'))
 642: {
 643:     /**
 644:      * Get the first element of an array. Useful for method chaining.
 645:      *
 646:      * @param  array  $array
 647:      * @return mixed
 648:      */
 649:     function head($array)
 650:     {
 651:         return reset($array);
 652:     }
 653: }
 654: 
 655: if ( ! function_exists('link_to'))
 656: {
 657:     /**
 658:      * Generate a HTML link.
 659:      *
 660:      * @param  string  $url
 661:      * @param  string  $title
 662:      * @param  array   $attributes
 663:      * @param  bool    $secure
 664:      * @return string
 665:      */
 666:     function link_to($url, $title = null, $attributes = array(), $secure = null)
 667:     {
 668:         return app('html')->link($url, $title, $attributes, $secure);
 669:     }
 670: }
 671: 
 672: if ( ! function_exists('last'))
 673: {
 674:     /**
 675:      * Get the last element from an array.
 676:      *
 677:      * @param  array  $array
 678:      * @return mixed
 679:      */
 680:     function last($array)
 681:     {
 682:         return end($array);
 683:     }
 684: }
 685: 
 686: if ( ! function_exists('link_to_asset'))
 687: {
 688:     /**
 689:      * Generate a HTML link to an asset.
 690:      *
 691:      * @param  string  $url
 692:      * @param  string  $title
 693:      * @param  array   $attributes
 694:      * @param  bool    $secure
 695:      * @return string
 696:      */
 697:     function link_to_asset($url, $title = null, $attributes = array(), $secure = null)
 698:     {
 699:         return app('html')->linkAsset($url, $title, $attributes, $secure);
 700:     }
 701: }
 702: 
 703: if ( ! function_exists('link_to_route'))
 704: {
 705:     /**
 706:      * Generate a HTML link to a named route.
 707:      *
 708:      * @param  string  $name
 709:      * @param  string  $title
 710:      * @param  array   $parameters
 711:      * @param  array   $attributes
 712:      * @return string
 713:      */
 714:     function link_to_route($name, $title = null, $parameters = array(), $attributes = array())
 715:     {
 716:         return app('html')->linkRoute($name, $title, $parameters, $attributes);
 717:     }
 718: }
 719: 
 720: if ( ! function_exists('link_to_action'))
 721: {
 722:     /**
 723:      * Generate a HTML link to a controller action.
 724:      *
 725:      * @param  string  $action
 726:      * @param  string  $title
 727:      * @param  array   $parameters
 728:      * @param  array   $attributes
 729:      * @return string
 730:      */
 731:     function link_to_action($action, $title = null, $parameters = array(), $attributes = array())
 732:     {
 733:         return app('html')->linkAction($action, $title, $parameters, $attributes);
 734:     }
 735: }
 736: 
 737: if ( ! function_exists('object_get'))
 738: {
 739:     /**
 740:      * Get an item from an object using "dot" notation.
 741:      *
 742:      * @param  object  $object
 743:      * @param  string  $key
 744:      * @param  mixed   $default
 745:      * @return mixed
 746:      */
 747:     function object_get($object, $key, $default = null)
 748:     {
 749:         if (is_null($key) || trim($key) == '') return $object;
 750: 
 751:         foreach (explode('.', $key) as $segment)
 752:         {
 753:             if ( ! is_object($object) || ! isset($object->{$segment}))
 754:             {
 755:                 return value($default);
 756:             }
 757: 
 758:             $object = $object->{$segment};
 759:         }
 760: 
 761:         return $object;
 762:     }
 763: }
 764: 
 765: if ( ! function_exists('preg_replace_sub'))
 766: {
 767:     /**
 768:      * Replace a given pattern with each value in the array in sequentially.
 769:      *
 770:      * @param  string  $pattern
 771:      * @param  array   $replacements
 772:      * @param  string  $subject
 773:      * @return string
 774:      */
 775:     function preg_replace_sub($pattern, &$replacements, $subject)
 776:     {
 777:         return preg_replace_callback($pattern, function($match) use (&$replacements)
 778:         {
 779:             return array_shift($replacements);
 780: 
 781:         }, $subject);
 782:     }
 783: }
 784: 
 785: if ( ! function_exists('public_path'))
 786: {
 787:     /**
 788:      * Get the path to the public folder.
 789:      *
 790:      * @param  string  $path
 791:      * @return string
 792:      */
 793:     function public_path($path = '')
 794:     {
 795:         return app()->make('path.public').($path ? '/'.$path : $path);
 796:     }
 797: }
 798: 
 799: if ( ! function_exists('route'))
 800: {
 801:     /**
 802:      * Generate a URL to a named route.
 803:      *
 804:      * @param  string  $route
 805:      * @param  array   $parameters
 806:      * @return string
 807:      */
 808:     function route($route, $parameters = array())
 809:     {
 810:         return app('url')->route($route, $parameters);
 811:     }
 812: }
 813: 
 814: if ( ! function_exists('secure_asset'))
 815: {
 816:     /**
 817:      * Generate an asset path for the application.
 818:      *
 819:      * @param  string  $path
 820:      * @return string
 821:      */
 822:     function secure_asset($path)
 823:     {
 824:         return asset($path, true);
 825:     }
 826: }
 827: 
 828: if ( ! function_exists('secure_url'))
 829: {
 830:     /**
 831:      * Generate a HTTPS url for the application.
 832:      *
 833:      * @param  string  $path
 834:      * @param  mixed   $parameters
 835:      * @return string
 836:      */
 837:     function secure_url($path, $parameters = array())
 838:     {
 839:         return url($path, $parameters, true);
 840:     }
 841: }
 842: 
 843: if ( ! function_exists('snake_case'))
 844: {
 845:     /**
 846:      * Convert a string to snake case.
 847:      *
 848:      * @param  string  $value
 849:      * @param  string  $delimiter
 850:      * @return string
 851:      */
 852:     function snake_case($value, $delimiter = '_')
 853:     {
 854:         return Illuminate\Support\Str::snake($value, $delimiter);
 855:     }
 856: }
 857: 
 858: if ( ! function_exists('starts_with'))
 859: {
 860:     /**
 861:      * Determine if a given string starts with a given substring.
 862:      *
 863:      * @param  string  $haystack
 864:      * @param  string|array  $needle
 865:      * @return bool
 866:      */
 867:     function starts_with($haystack, $needle)
 868:     {
 869:         return Illuminate\Support\Str::startsWith($haystack, $needle);
 870:     }
 871: }
 872: 
 873: if ( ! function_exists('storage_path'))
 874: {
 875:     /**
 876:      * Get the path to the storage folder.
 877:      *
 878:      * @param   string  $path
 879:      * @return  string
 880:      */
 881:     function storage_path($path = '')
 882:     {
 883:         return app('path.storage').($path ? '/'.$path : $path);
 884:     }
 885: }
 886: 
 887: if ( ! function_exists('str_contains'))
 888: {
 889:     /**
 890:      * Determine if a given string contains a given substring.
 891:      *
 892:      * @param  string  $haystack
 893:      * @param  string|array  $needle
 894:      * @return bool
 895:      */
 896:     function str_contains($haystack, $needle)
 897:     {
 898:         return Illuminate\Support\Str::contains($haystack, $needle);
 899:     }
 900: }
 901: 
 902: if ( ! function_exists('str_finish'))
 903: {
 904:     /**
 905:      * Cap a string with a single instance of a given value.
 906:      *
 907:      * @param  string  $value
 908:      * @param  string  $cap
 909:      * @return string
 910:      */
 911:     function str_finish($value, $cap)
 912:     {
 913:         return Illuminate\Support\Str::finish($value, $cap);
 914:     }
 915: }
 916: 
 917: if ( ! function_exists('str_is'))
 918: {
 919:     /**
 920:      * Determine if a given string matches a given pattern.
 921:      *
 922:      * @param  string  $pattern
 923:      * @param  string  $value
 924:      * @return bool
 925:      */
 926:     function str_is($pattern, $value)
 927:     {
 928:         return Illuminate\Support\Str::is($pattern, $value);
 929:     }
 930: }
 931: 
 932: if ( ! function_exists('str_limit'))
 933: {
 934:         /**
 935:          * Limit the number of characters in a string.
 936:          *
 937:          * @param  string  $value
 938:          * @param  int     $limit
 939:          * @param  string  $end
 940:          * @return string
 941:          */
 942:         function str_limit($value, $limit = 100, $end = '...')
 943:         {
 944:                 return Illuminate\Support\Str::limit($value, $limit, $end);
 945:         }
 946: }
 947: 
 948: if ( ! function_exists('str_plural'))
 949: {
 950:     /**
 951:      * Get the plural form of an English word.
 952:      *
 953:      * @param  string  $value
 954:      * @param  int  $count
 955:      * @return string
 956:      */
 957:     function str_plural($value, $count = 2)
 958:     {
 959:         return Illuminate\Support\Str::plural($value, $count);
 960:     }
 961: }
 962: 
 963: if ( ! function_exists('str_random'))
 964: {
 965:     /**
 966:      * Generate a more truly "random" alpha-numeric string.
 967:      *
 968:      * @param  int     $length
 969:      * @return string
 970:      *
 971:      * @throws \RuntimeException
 972:      */
 973:     function str_random($length = 16)
 974:     {
 975:         return Illuminate\Support\Str::random($length);
 976:     }
 977: }
 978: 
 979: if ( ! function_exists('str_replace_array'))
 980: {
 981:     /**
 982:      * Replace a given value in the string sequentially with an array.
 983:      *
 984:      * @param  string  $search
 985:      * @param  array   $replace
 986:      * @param  string  $subject
 987:      * @return string
 988:      */
 989:     function str_replace_array($search, array $replace, $subject)
 990:     {
 991:         foreach ($replace as $value)
 992:         {
 993:             $subject = preg_replace('/'.$search.'/', $value, $subject, 1);
 994:         }
 995: 
 996:         return $subject;
 997:     }
 998: }
 999: 
1000: if ( ! function_exists('str_singular'))
1001: {
1002:     /**
1003:      * Get the singular form of an English word.
1004:      *
1005:      * @param  string  $value
1006:      * @return string
1007:      */
1008:     function str_singular($value)
1009:     {
1010:         return Illuminate\Support\Str::singular($value);
1011:     }
1012: }
1013: 
1014: if ( ! function_exists('studly_case'))
1015: {
1016:     /**
1017:      * Convert a value to studly caps case.
1018:      *
1019:      * @param  string  $value
1020:      * @return string
1021:      */
1022:     function studly_case($value)
1023:     {
1024:         return Illuminate\Support\Str::studly($value);
1025:     }
1026: }
1027: 
1028: if ( ! function_exists('trans'))
1029: {
1030:     /**
1031:      * Translate the given message.
1032:      *
1033:      * @param  string  $id
1034:      * @param  array   $parameters
1035:      * @param  string  $domain
1036:      * @param  string  $locale
1037:      * @return string
1038:      */
1039:     function trans($id, $parameters = array(), $domain = 'messages', $locale = null)
1040:     {
1041:         return app('translator')->trans($id, $parameters, $domain, $locale);
1042:     }
1043: }
1044: 
1045: if ( ! function_exists('trans_choice'))
1046: {
1047:     /**
1048:      * Translates the given message based on a count.
1049:      *
1050:      * @param  string  $id
1051:      * @param  int     $number
1052:      * @param  array   $parameters
1053:      * @param  string  $domain
1054:      * @param  string  $locale
1055:      * @return string
1056:      */
1057:     function trans_choice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
1058:     {
1059:         return app('translator')->transChoice($id, $number, $parameters, $domain, $locale);
1060:     }
1061: }
1062: 
1063: if ( ! function_exists('url'))
1064: {
1065:     /**
1066:      * Generate a url for the application.
1067:      *
1068:      * @param  string  $path
1069:      * @param  mixed   $parameters
1070:      * @param  bool    $secure
1071:      * @return string
1072:      */
1073:     function url($path = null, $parameters = array(), $secure = null)
1074:     {
1075:         return app('url')->to($path, $parameters, $secure);
1076:     }
1077: }
1078: 
1079: if ( ! function_exists('value'))
1080: {
1081:     /**
1082:      * Return the default value of the given value.
1083:      *
1084:      * @param  mixed  $value
1085:      * @return mixed
1086:      */
1087:     function value($value)
1088:     {
1089:         return $value instanceof Closure ? $value() : $value;
1090:     }
1091: }
1092: 
1093: if ( ! function_exists('with'))
1094: {
1095:     /**
1096:      * Return the given object. Useful for chaining.
1097:      *
1098:      * @param  mixed  $object
1099:      * @return mixed
1100:      */
1101:     function with($object)
1102:     {
1103:         return $object;
1104:     }
1105: }
1106: 
API documentation generated by ApiGen 2.8.0