1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-07 13:46:42 +02:00

feat(shortcodes): [strings] shortcode - add crc32 modifier

This commit is contained in:
Awilum
2022-05-05 08:24:29 +03:00
parent 336f2c5daa
commit 09d9740b58
2 changed files with 7 additions and 0 deletions

View File

@@ -130,6 +130,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
$content = (string) strings($content)->{'count'}();
}
if ($key == 'crc32') {
$content = (string) strings($content)->{'crc32'}();
}
if ($key == 'countSubString') {
$content = (string) strings($content)->{'countSubString'}(isset($vars[0]) ? (string) $vars[0] : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : true);
}

View File

@@ -85,4 +85,7 @@ test('[strings] shortcode', function () {
$this->assertEquals(1, parsers()->shortcodes()->parse('[strings countSubString=test]Test string here for test[/strings]'));
$this->assertEquals(2, parsers()->shortcodes()->parse('[strings countSubString=test|false]Test string here for test[/strings]'));
// crc32
$this->assertEquals(3632233996, parsers()->shortcodes()->parse('[strings crc32]test[/strings]'));
});