maximo-perez-villalba / tool-txt
TXT类聚合了各种瑞士军刀式的文本处理工具。
1.0.0
2022-08-03 03:23 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^9.4
README
TXT类聚合了各种瑞士军刀式的文本处理工具。
工具
startWith
$txt = TXT::create( "Lorem ipsum..." ); $txt->startWith('Lorem '); //TRUE
endWith
TXT::create( "Lorem ipsum..." )->endWith('...'); //TRUE
equals
$text = $otherText = 'Lorem ipsum...'; TXT::create($text)->equals($otherText); //TRUE
compare
安全的字符串比较。如果$ext小于$otherText,则返回 < 0;如果$text大于$otherText,则返回 > 0;如果相等,则返回 0。@see https://php.ac.cn/manual/zh/function.strcmp.php
$text = $otherText = 'Lorem ipsum...'; TXT::create($text)->compare($otherText) === 0; //TRUE
contains
TXT::create('Lorem ipsum...')->contains('rem ip'); //TRUE
lastPart
TXT::create('Lorem|ipsum')->lastPart('|'); //ipsum TXT::create('Lorem|ipsum')->lastPart('|', TRUE); //|ipsum
firstPart
TXT::create('Lorem|ipsum')->firstPart('|'); //Lorem TXT::create('Lorem|ipsum')->firstPart('|', TRUE); //Lorem|
toCamelCaseClass
TXT::create('mAke_mE camel-case pLEase')->toCamelCaseClass() == 'MakeMeCamelCasePlease'; //TRUE
toCamelCaseVariable
TXT::create('MAke_mE camel-case pLEase')->toCamelCaseVariable() == 'makeMeCamelCasePlease'; //TRUE