From d85c5fb8148a1d0a360528d88db1abb1ef653503 Mon Sep 17 00:00:00 2001 From: Ashley Allen Date: Fri, 10 Apr 2020 22:30:48 +0100 Subject: [PATCH 1/3] Added a new 'ShortURL' facade. --- composer.json | 3 ++- src/Facades/ShortURL.php | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/Facades/ShortURL.php diff --git a/composer.json b/composer.json index bf70aab..2738c94 100755 --- a/composer.json +++ b/composer.json @@ -46,7 +46,8 @@ "AshAllenDesign\\ShortURL\\Providers\\ShortURLProvider" ], "aliases": { - "ShortURLBuilder": "AshAllenDesign\\ShortURL\\Facades\\ShortURLBuilder" + "ShortURLBuilder": "AshAllenDesign\\ShortURL\\Facades\\ShortURLBuilder", + "ShortURL": "AshAllenDesign\\ShortURL\\Facades\\ShortURL" } } } diff --git a/src/Facades/ShortURL.php b/src/Facades/ShortURL.php new file mode 100644 index 0000000..1d1490c --- /dev/null +++ b/src/Facades/ShortURL.php @@ -0,0 +1,41 @@ + Date: Fri, 10 Apr 2020 22:31:04 +0100 Subject: [PATCH 2/3] Added a deprecation warning to the ShortURLBuilder facade. --- src/Facades/ShortURLBuilder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Facades/ShortURLBuilder.php b/src/Facades/ShortURLBuilder.php index 3e0d0a6..9af5ad5 100644 --- a/src/Facades/ShortURLBuilder.php +++ b/src/Facades/ShortURLBuilder.php @@ -25,6 +25,8 @@ * @method static ShortURL make() * * @see Builder + * + * @deprecated since v3.0.0. This class will be removed in v4.0.0. Use the newer 'ShortURL' facade. */ class ShortURLBuilder extends Facade { From 48bed950cf86e72848cd89b360c97f2ff5fc3b48 Mon Sep 17 00:00:00 2001 From: Ashley Allen Date: Fri, 10 Apr 2020 22:31:21 +0100 Subject: [PATCH 3/3] Updated tests to use the newer ShortURL facade. --- tests/Unit/Classes/BuilderTest.php | 8 ++++---- tests/Unit/TestCase.php | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Unit/Classes/BuilderTest.php b/tests/Unit/Classes/BuilderTest.php index c410ec1..f5d72f8 100644 --- a/tests/Unit/Classes/BuilderTest.php +++ b/tests/Unit/Classes/BuilderTest.php @@ -9,7 +9,7 @@ use AshAllenDesign\ShortURL\Tests\Unit\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Config; -use ShortURLBuilder; +use ShortURL as ShortURLAlias; class BuilderTest extends TestCase { @@ -295,7 +295,7 @@ public function short_url_can_be_created_and_stored_in_the_database() /** @test */ public function short_url_can_be_created_and_stored_in_the_database_using_the_facade() { - ShortURLBuilder::destinationUrl('http://domain.com') + ShortURLAlias::destinationUrl('http://domain.com') ->urlKey('customKey') ->secure() ->trackVisits(false) @@ -314,7 +314,7 @@ public function short_url_can_be_created_and_stored_in_the_database_using_the_fa /** @test */ public function correct_redirect_status_code_is_stored_if_explicitly_set() { - ShortURLBuilder::destinationUrl('http://domain.com') + ShortURLAlias::destinationUrl('http://domain.com') ->urlKey('customKey') ->secure() ->trackVisits(false) @@ -337,7 +337,7 @@ public function exception_is_thrown_if_the_redirect_status_code_is_not_valid() $this->expectException(ShortURLException::class); $this->expectExceptionMessage('The redirect status code must be a valid redirect HTTP status code.'); - ShortURLBuilder::destinationUrl('http://domain.com') + ShortURLAlias::destinationUrl('http://domain.com') ->urlKey('customKey') ->secure() ->trackVisits(false) diff --git a/tests/Unit/TestCase.php b/tests/Unit/TestCase.php index e536eb9..8dd3eca 100755 --- a/tests/Unit/TestCase.php +++ b/tests/Unit/TestCase.php @@ -2,6 +2,7 @@ namespace AshAllenDesign\ShortURL\Tests\Unit; +use AshAllenDesign\ShortURL\Facades\ShortURL; use AshAllenDesign\ShortURL\Facades\ShortURLBuilder; use AshAllenDesign\ShortURL\Providers\ShortURLProvider; use Illuminate\Foundation\Application; @@ -32,6 +33,7 @@ protected function getPackageAliases($app) { return [ 'ShortURLBuilder' => ShortURLBuilder::class, + 'ShortURL' => ShortURL::class, ]; }