diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a3bddfe --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added +- New method `mb_ucfirst`. + +### Changed +- Sources are now located inside `src` folder. +- [Minor BC Break] many parameters `encoding` are suppressed because processing is faster without and they are not + mandatory. _This change doesn't break your code but may in the future if we add new parameters._ + +### Fixed +- Unicode usage for `camelize` method. + +## [1.0.0] - 2016-11-3 + +### Added + +- StringTools class. +- EqualableInterface interface. diff --git a/README.md b/README.md index 0f7add0..37ac20e 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,17 @@ Reference #### ::camelize ```php -StringTools::camelize($str, $from) : string +StringTools::camelize($str, $from, $encoding) : string ``` * `$str` string input -* `$from` (optional, default "\_") string entry format (can be "-" or "\_") +* `$from` (optional, default "\_") input string format (can be "-" or "\_") +* `$encoding` (optional, default "UTF-8") encoding of your input string #### ::startsWith +Say if the given string starts with needle or not. + ```php StringTools::startsWith($str, $start) : bool ``` @@ -41,8 +44,10 @@ StringTools::startsWith($str, $start) : bool #### ::endsWith +Say if the given string ends with needle or not. + ```php -StringTools::endsWith($str, $end, $encoding) : bool +StringTools::endsWith($str, $end) : bool ``` * `$str` string input @@ -50,8 +55,10 @@ StringTools::endsWith($str, $end, $encoding) : bool #### ::removeStart +Removes the start of the string if it matches with the given one. + ```php -StringTools::removeStart($str, $toRemove, $encoding) : string +StringTools::removeStart($str, $toRemove) : string ``` * `$str` string input @@ -60,12 +67,23 @@ StringTools::removeStart($str, $toRemove, $encoding) : string #### ::contains ```php -StringTools::contains($str, $needle, $encoding) : bool +StringTools::contains($str, $needle) : bool ``` * `$str` string input * `$needle` potentially contained string +#### ::mb_ucfirst + +Adds missing multi-byte PHP function for `ucfirst` standard function. + +``` +StringTools::mb_ucfirst($str, $encoding) : string +``` + +* `$str` string input +* `$encoding` (optional, default "UTF-8") encoding of your input string + ### EqualableInterface Helps you equals on objects on a similar way as [java](http://stackoverflow.com/questions/1643067/whats-the-difference-between-equals-and). diff --git a/StringTools.php b/StringTools.php deleted file mode 100644 index c52d7c8..0000000 --- a/StringTools.php +++ /dev/null @@ -1,80 +0,0 @@ -shouldReturn(true); $this::contains('Hello 👽 aliens !', 'aliens')->shouldReturn(true); } + + function it_should_uppercase_first_letter_with_ucfirst() + { + $this::mb_ucfirst('hello')->shouldReturn('Hello'); + $this::mb_ucfirst('helloWorlD')->shouldReturn('HelloWorlD'); + $this::mb_ucfirst('HelloWorld')->shouldReturn('HelloWorld'); + $this::mb_ucfirst('🍕isReallyGood')->shouldReturn('🍕isReallyGood'); + } } diff --git a/EqualableInterface.php b/src/EqualableInterface.php similarity index 100% rename from EqualableInterface.php rename to src/EqualableInterface.php diff --git a/src/StringTools.php b/src/StringTools.php new file mode 100644 index 0000000..b72c054 --- /dev/null +++ b/src/StringTools.php @@ -0,0 +1,105 @@ +