Skip to content

[enh] Proposal to add class StringObject #6

Description

@rugabarbo

I propose to add class StringObject. Then it will be possible to manipulate strings in object-oriented style:

$baseWord = newStringObject('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
{
publicstaticfunctioncreateObject(string$string, string$encoding = null): StringObject
{
returnnewStringObject($string, $encoding);
}
publicstaticfunctionwordsCount(string$string, string$encoding = null): int
{
returnstatic::createObject($string, $encoding)->wordsCount();
}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions