From dfb50d5f0aba798e00af99b99a39227875e006e6 Mon Sep 17 00:00:00 2001 From: Mo Khosh Date: Sun, 3 Nov 2024 18:02:01 +0330 Subject: [PATCH] add hex strategy --- src/Strategies/Link/Hex.php | 34 +++++++++++++++++++++++++++++++ tests/Strategies/Link/HexTest.php | 10 +++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/Strategies/Link/Hex.php create mode 100644 tests/Strategies/Link/HexTest.php diff --git a/src/Strategies/Link/Hex.php b/src/Strategies/Link/Hex.php new file mode 100644 index 0000000..6a24bf6 --- /dev/null +++ b/src/Strategies/Link/Hex.php @@ -0,0 +1,34 @@ + + HTML; + + return "".$title.$script; + } + + public function unmuddle(string $string): string + { + preg_match('/ \^ (\d+)/', $string, $key); + preg_match('/href=\'([^\']+)\'>/', $string, $hexed); + preg_match('/>([^<]+)<\/a>/', $string, $title); + + return '$title[1]"; + } +} diff --git a/tests/Strategies/Link/HexTest.php b/tests/Strategies/Link/HexTest.php new file mode 100644 index 0000000..53b3b4c --- /dev/null +++ b/tests/Strategies/Link/HexTest.php @@ -0,0 +1,10 @@ +muddle('test@example.com', 'email')) + ->not->toBe('email') + ->and((new Hex)->unmuddle($muddled)) + ->toBe('email'); +});