From 609920b0d028ce898bf10bc0a58a887908b3299a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 4 Apr 2012 14:30:32 -0500 Subject: [PATCH] Allow str_contains to take an array. Signed-off-by: Taylor Otwell --- laravel/helpers.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/laravel/helpers.php b/laravel/helpers.php index 9caf55ff..f050d152 100644 --- a/laravel/helpers.php +++ b/laravel/helpers.php @@ -340,13 +340,18 @@ function ends_with($haystack, $needle) /** * Determine if a given string contains a given sub-string. * - * @param string $haystack - * @param string $needle + * @param string $haystack + * @param string|array $needle * @return bool */ function str_contains($haystack, $needle) { - return strpos($haystack, $needle) !== false; + foreach ((array) $needle as $n) + { + if (strpos($haystack, $n) !== false) return true; + } + + return false; } /** @@ -361,17 +366,6 @@ function str_finish($value, $cap) return rtrim($value, $cap).$cap; } -/** - * Determine if the given object has a toString method. - * - * @param object $value - * @return bool - */ -function str_object($value) -{ - return is_object($value) and method_exists($value, '__toString'); -} - /** * Get the root namespace of a given class. *