Skip to content

Commit

Permalink
fixing cons
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 5, 2016
2 parents d4365d6 + 5f6c1cf commit 8495627
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function camel($value)
public static function contains($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle != '' && strpos($haystack, $needle) !== false) {
if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
return true;
}
}
Expand All @@ -87,7 +87,7 @@ public static function contains($haystack, $needles)
public static function endsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ((string) $needle === substr($haystack, -strlen($needle))) {
if ((string) $needle === static::substr($haystack, -static::length($needle))) {
return true;
}
}
Expand All @@ -106,7 +106,7 @@ public static function finish($value, $cap)
{
$quoted = preg_quote($cap, '/');

return preg_replace('/(?:'.$quoted.')+$/', '', $value).$cap;
return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
}

/**
Expand All @@ -129,7 +129,7 @@ public static function is($pattern, $value)
// pattern such as "library/*", making any string check convenient.
$pattern = str_replace('\*', '.*', $pattern);

return (bool) preg_match('#^'.$pattern.'\z#', $value);
return (bool) preg_match('#^'.$pattern.'\z#u', $value);
}

/**
Expand Down Expand Up @@ -183,7 +183,7 @@ public static function words($value, $words = 100, $end = '...')
{
preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);

if (! isset($matches[0]) || strlen($value) === strlen($matches[0])) {
if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) {
return $value;
}

Expand Down Expand Up @@ -224,12 +224,12 @@ public static function random($length = 16)
{
$string = '';

while (($len = strlen($string)) < $length) {
while (($len = static::length($string)) < $length) {
$size = $length - $len;

$bytes = random_bytes($size);

$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
$string .= static::substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
}

return $string;
Expand Down Expand Up @@ -260,7 +260,7 @@ public static function quickRandom($length = 16)
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

return substr(str_shuffle(str_repeat($pool, $length)), 0, $length);
return static::substr(str_shuffle(str_repeat($pool, $length)), 0, $length);
}

/**
Expand Down Expand Up @@ -393,9 +393,9 @@ public static function snake($value, $delimiter = '_')
}

if (! ctype_lower($value)) {
$value = preg_replace('/\s+/', '', $value);
$value = preg_replace('/\s+/u', '', $value);

$value = static::lower(preg_replace('/(.)(?=[A-Z])/', '$1'.$delimiter, $value));
$value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
}

return static::$snakeCache[$key] = $value;
Expand All @@ -411,7 +411,7 @@ public static function snake($value, $delimiter = '_')
public static function startsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle != '' && strpos($haystack, $needle) === 0) {
if ($needle != '' && mb_strpos($haystack, $needle) === 0) {
return true;
}
}
Expand Down

0 comments on commit 8495627

Please sign in to comment.