mirror of
https://github.com/flextype/flextype.git
synced 2025-08-06 13:16:45 +02:00
feat(shortcodes): [strings]
shortcode - add charsFrequency
modifier
This commit is contained in:
@@ -108,6 +108,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa
|
||||
if ($key == 'chars') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'chars'}());
|
||||
}
|
||||
|
||||
if ($key == 'charsFrequency') {
|
||||
$content = serializers()->json()->encode(strings($content)->{'charsFrequency'}());
|
||||
}
|
||||
}
|
||||
|
||||
return (string) $content;
|
||||
|
@@ -58,4 +58,7 @@ test('[strings] shortcode', function () {
|
||||
// chars
|
||||
$this->assertEquals('["c","a","r","_","f","ò","ô","_","b","à","ř","s","_","a","p","p","l","e"]', parsers()->shortcodes()->parse('[strings chars]car_fòô_bàřs_apple[/strings]'));
|
||||
|
||||
// charsFrequency
|
||||
$this->assertEquals('{"_":"16.67","a":"11.11","p":"11.11","c":"5.56","r":"5.56","f":"5.56","ò":"5.56","ô":"5.56","b":"5.56","à":"5.56","ř":"5.56","s":"5.56","l":"5.56","e":"5.56"}', parsers()->shortcodes()->parse('[strings charsFrequency]car_fòô_bàřs_apple[/strings]'));
|
||||
|
||||
});
|
Reference in New Issue
Block a user