diff --git a/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php b/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php index 9d3fa929..5a979412 100644 --- a/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php @@ -22,39 +22,22 @@ use function app; use function parsers; use function registry; -// Shortcode: [uuid1] -parsers()->shortcodes()->addHandler('uuid1', static function () { +// Shortcode: uuid +// Usage: (uuid) (uuid:4) +parsers()->shortcodes()->addHandler('uuid', 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 ''; + $result = ''; + $uuid = ($s->getBbCode() != null) ? strings(parsers()->shortcodes()->parse($s->getBbCode()))->toInteger() : 4; + + switch ($uuid) { + case 4: + default: + $result = Uuid::uuid4()->toString(); + break; } - 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(); + return $result; }); \ 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 deleted file mode 100644 index b92a482a..00000000 --- a/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcode.php +++ /dev/null @@ -1,10 +0,0 @@ -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 diff --git a/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcodeTest.php b/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcodeTest.php index b9a019fe..1d050ca8 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/UuidShortcodeTest.php @@ -2,9 +2,7 @@ declare(strict_types=1); -test('uuid shortcode', function () { - expect(strings(parsers()->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(); +test('uuid shortcode', function () { + expect(strings(parsers()->shortcodes()->parse('(uuid)'))->length() > 0)->toBeTrue(); + expect(strings(parsers()->shortcodes()->parse('(uuid:4)'))->length() > 0)->toBeTrue(); }); \ No newline at end of file