$class], class_parents($class)) as $class) { $results += trait_uses_recursive($class); } return array_unique($results); } } if (! function_exists('collect')) { /** * Create a collection from the given value. * * @param mixed $value * @return \Illuminate\Support\Collection */ function collect($value = null) { return new Collection($value); } } if (! function_exists('data_get')) { /** * Get an item from an array or object using "dot" notation. * * @param mixed $target * @param string|array $key * @param mixed $default * @return mixed */ function data_get($target, $key, $default = null) { if (is_null($key)) { return $target; } $key = is_array($key) ? $key : explode('.', $key); foreach ($key as $segment) { if (is_array($target)) { if (! array_key_exists($segment, $target)) { return value($default); } $target = $target[$segment]; } elseif ($target instanceof ArrayAccess) { if (! isset($target[$segment])) { return value($default); } $target = $target[$segment]; } elseif (is_object($target)) { if (! isset($target->{$segment})) { return value($default); } $target = $target->{$segment}; } else { return value($default); } } return $target; } } if (! function_exists('ends_with')) { /** * Determine if a given string ends with a given substring. * * @param string $haystack * @param string|array $needles * @return bool */ function ends_with($haystack, $needles) { return Str::endsWith($haystack, $needles); } } if (! function_exists('preg_replace_sub')) { /** * Replace a given pattern with each value in the array in sequentially. * * @param string $pattern * @param array $replacements * @param string $subject * @return string */ function preg_replace_sub($pattern, &$replacements, $subject) { return preg_replace_callback($pattern, function ($match) use (&$replacements) { foreach ($replacements as $key => $value) { return array_shift($replacements); } }, $subject); } } if (! function_exists('snake_case')) { /** * Convert a string to snake case. * * @param string $value * @param string $delimiter * @return string */ function snake_case($value, $delimiter = '_') { return Str::snake($value, $delimiter); } } if (! function_exists('starts_with')) { /** * Determine if a given string starts with a given substring. * * @param string $haystack * @param string|array $needles * @return bool */ function starts_with($haystack, $needles) { return Str::startsWith($haystack, $needles); } } if (! function_exists('str_contains')) { /** * Determine if a given string contains a given substring. * * @param string $haystack * @param string|array $needles * @return bool */ function str_contains($haystack, $needles) { return Str::contains($haystack, $needles); } } if (! function_exists('str_finish')) { /** * Cap a string with a single instance of a given value. * * @param string $value * @param string $cap * @return string */ function str_finish($value, $cap) { return Str::finish($value, $cap); } } if (! function_exists('str_is')) { /** * Determine if a given string matches a given pattern. * * @param string $pattern * @param string $value * @return bool */ function str_is($pattern, $value) { return Str::is($pattern, $value); } } if (! function_exists('str_limit')) { /** * Limit the number of characters in a string. * * @param string $value * @param int $limit * @param string $end * @return string */ function str_limit($value, $limit = 100, $end = '...') { return Str::limit($value, $limit, $end); } } if (! function_exists('str_plural')) { /** * Get the plural form of an English word. * * @param string $value * @param int $count * @return string */ function str_plural($value, $count = 2) { return Str::plural($value, $count); } } if (! function_exists('str_random')) { /** * Generate a more truly "random" alpha-numeric string. * * @param int $length * @return string * * @throws \RuntimeException */ function str_random($length = 16) { return Str::random($length); } } if (! function_exists('str_replace_array')) { /** * Replace a given value in the string sequentially with an array. * * @param string $search * @param array $replace * @param string $subject * @return string */ function str_replace_array($search, array $replace, $subject) { foreach ($replace as $value) { $subject = preg_replace('/'.$search.'/', $value, $subject, 1); } return $subject; } } if (! function_exists('str_singular')) { /** * Get the singular form of an English word. * * @param string $value * @return string */ function str_singular($value) { return Str::singular($value); } } if (! function_exists('str_slug')) { /** * Generate a URL friendly "slug" from a given string. * * @param string $title * @param string $separator * @return string */ function str_slug($title, $separator = '-') { return Str::slug($title, $separator); } } if (! function_exists('studly_case')) { /** * Convert a value to studly caps case. * * @param string $value * @return string */ function studly_case($value) { return Str::studly($value); } } if (! function_exists('title_case')) { /** * Convert a value to title case. * * @param string $value * @return string */ function title_case($value) { return Str::title($value); } } if (! function_exists('make')) { /** * @param $abstract * @param array $parameters * @return mixed * @throws @\Illuminate\Contracts\Container\BindingResolutionException */ function make($abstract, array $parameters = []) { return app()->make($abstract, $parameters = []); } }