Skip to content

Commit

Permalink
Merge pull request #3 from Nekland/Nek--patch-1
Browse files Browse the repository at this point in the history
Simplify the startsWith method
  • Loading branch information
Nek- authored Aug 1, 2017
2 parents e0218c6 + ebbdaef commit 4ad260e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions StringTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ public static function camelize($str, $from = '_')
/**
* @param string $str
* @param string $start
* @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) === $start;
}

/**
Expand Down

0 comments on commit 4ad260e

Please sign in to comment.