diff --git a/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php b/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php new file mode 100644 index 00000000..9d3fa929 --- /dev/null +++ b/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php @@ -0,0 +1,60 @@ +shortcodes()->addHandler('uuid1', static function () { + if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.uuid.enabled')) { + return ''; + } + + return Uuid::uuid1()->toString(); +}); + +// Shortcode: [uuid2] +parsers()->shortcodes()->addHandler('uuid2', static function () { + if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.uuid.enabled')) { + return ''; + } + + return Uuid::uuid2()->toString(); +}); + +// Shortcode: [uuid3] +parsers()->shortcodes()->addHandler('uuid3', static function () { + if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.uuid.enabled')) { + return ''; + } + + return Uuid::uuid3()->toString(); +}); + + +// Shortcode: [uuid4] +parsers()->shortcodes()->addHandler('uuid4', static function () { + if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.uuid.enabled')) { + return ''; + } + + return Uuid::uuid4()->toString(); +}); \ No newline at end of file diff --git a/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php b/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php new file mode 100644 index 00000000..931b0a91 --- /dev/null +++ b/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php @@ -0,0 +1,10 @@ +shortcodes()->parse('[uuid1]'))->length() > 0)->toBeTrue(); + expect(strings(parsers()->shortcodes()->parse('[uuid2]'))->length() > 0)->toBeTrue(); + expect(strings(parsers()->shortcodes()->parse('[uuid3]'))->length() > 0)->toBeTrue(); + expect(strings(parsers()->shortcodes()->parse('[uuid4]'))->length() > 0)->toBeTrue(); +}); \ No newline at end of file