From 43ce0236322e173a7879970afaad7788fa329945 Mon Sep 17 00:00:00 2001 From: Maxime Veber Date: Tue, 9 May 2017 17:48:18 +0200 Subject: [PATCH 1/3] Simplify the startsWith method --- StringTools.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/StringTools.php b/StringTools.php index 679f6ca..1b2a7bd 100644 --- a/StringTools.php +++ b/StringTools.php @@ -24,11 +24,11 @@ public static function camelize($str, $from = '_') * @param string $encoding * @return bool */ - public static function startsWith($str, $start, $encoding = 'UTF-8') + public static function startsWith($str, $start) { - $length = mb_strlen($start, $encoding); + $length = strlen($start); - return mb_substr($str, 0, $length, $encoding) === $start; + return substr($str, 0, $length, $encoding) === $start; } /** From 51d18251c2d01f84b5679da7c4f4d656c05da487 Mon Sep 17 00:00:00 2001 From: Maxime Veber Date: Tue, 9 May 2017 17:53:16 +0200 Subject: [PATCH 2/3] Fix wrong encoding var in startsWith --- StringTools.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StringTools.php b/StringTools.php index 1b2a7bd..9bd6d11 100644 --- a/StringTools.php +++ b/StringTools.php @@ -28,7 +28,7 @@ public static function startsWith($str, $start) { $length = strlen($start); - return substr($str, 0, $length, $encoding) === $start; + return substr($str, 0, $length) === $start; } /** From ebbdaefa157a2d943300bc90609c49723c7b94ea Mon Sep 17 00:00:00 2001 From: Maxime Veber Date: Tue, 1 Aug 2017 12:22:31 +0200 Subject: [PATCH 3/3] Fix doc for startsWith --- README.md | 2 +- StringTools.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f773225..0f7add0 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ StringTools::camelize($str, $from) : string #### ::startsWith ```php -StringTools::startsWith($str, $start, $encoding) : bool +StringTools::startsWith($str, $start) : bool ``` * `$str` string input diff --git a/StringTools.php b/StringTools.php index 9bd6d11..c52d7c8 100644 --- a/StringTools.php +++ b/StringTools.php @@ -21,7 +21,6 @@ public static function camelize($str, $from = '_') /** * @param string $str * @param string $start - * @param string $encoding * @return bool */ public static function startsWith($str, $start)