Phalcon text
NOTE
All classes are prefixed with Phalcon
Text¶
-
Namespace
Phalcon
-
Uses
Phalcon\Helper\Str
-
Extends
-
Implements
Provides utilities to work with texts
Constants¶
const RANDOM_ALNUM = 0;
const RANDOM_ALPHA = 1;
const RANDOM_DISTINCT = 5;
const RANDOM_HEXDEC = 2;
const RANDOM_NOZERO = 4;
const RANDOM_NUMERIC = 3;
Methods¶
Converts strings to camelize styleecho Phalcon\Text::camelize("coco_bongo"); // CocoBongo
echo Phalcon\Text::camelize("co_co-bon_go", "-"); // Co_coBon_go
echo Phalcon\Text::camelize("co_co-bon_go", "_-"); // CoCoBonGo
$str = Phalcon\Text::concat(
"/",
"/tmp/",
"/folder_1/",
"/folder_2",
"folder_3/"
);
// /tmp/folder_1/folder_2/folder_3/
echo $str;
public static function dynamic( string $text, string $leftDelimiter = string, string $rightDelimiter = string, string $separator = string ): string;
// Hi my name is a Bob
echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!");
// Hi my name is a Jon
echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!");
// Hello my name is a Bob
echo Phalcon\Text::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!");
// Hello my name is a Zyxep
echo Phalcon\Text::dynamic(
"[Hi/Hello], my name is a [Zyxep/Mark]!",
"[", "]",
"/"
);
echo Phalcon\Text::endsWith("Hello", "llo"); // true
echo Phalcon\Text::endsWith("Hello", "LLO", false); // false
echo Phalcon\Text::endsWith("Hello", "LLO"); // true
echo Phalcon\Text::humanize("start-a-horse"); // "start a horse"
echo Phalcon\Text::humanize("five_cats"); // "five cats"
// foo/bar/baz
echo Phalcon\Text::reduceSlashes("foo//bar/baz");
// http://foo.bar/baz/buz
echo Phalcon\Text::reduceSlashes("http://foo.bar///baz/buz");
echo Phalcon\Text::startsWith("Hello", "He"); // true
echo Phalcon\Text::startsWith("Hello", "he", false); // false
echo Phalcon\Text::startsWith("Hello", "he"); // true
echo Phalcon\Text::uncamelize("CocoBongo"); // coco_bongo
echo Phalcon\Text::uncamelize("CocoBongo", "-"); // coco-bongo