-
-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
status:ready for adoptionFeel free to implement this issue.Feel free to implement this issue.type:featureNew featureNew feature
Description
I propose to add class StringObject. Then it will be possible to manipulate strings in object-oriented style:
$baseWord = new StringObject('soft', 'UTF-8');
$projectName = $baseWord
->preprend('yii')
->addWord('project')
->upperCaseEveryWord();
$projectNameWordsCount = $projectName->wordsCount();Then we can make class StringHelper a wrapper over class StringObject. For example:
class StringHelper
{
public static function createObject(string $string, string $encoding = null): StringObject
{
return new StringObject($string, $encoding);
}
public static function wordsCount(string $string, string $encoding = null): int
{
return static::createObject($string, $encoding)->wordsCount();
}
}Metadata
Metadata
Assignees
Labels
status:ready for adoptionFeel free to implement this issue.Feel free to implement this issue.type:featureNew featureNew feature