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:
@@ -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);
|
||||
}
|
||||
|
@@ -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]'));
|
||||
|
||||
});
|
Reference in New Issue
Block a user