Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new ShortURL facade. #45

Merged
merged 3 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"AshAllenDesign\\ShortURL\\Providers\\ShortURLProvider"
],
"aliases": {
"ShortURLBuilder": "AshAllenDesign\\ShortURL\\Facades\\ShortURLBuilder"
"ShortURLBuilder": "AshAllenDesign\\ShortURL\\Facades\\ShortURLBuilder",
"ShortURL": "AshAllenDesign\\ShortURL\\Facades\\ShortURL"
}
}
}
Expand Down
41 changes: 41 additions & 0 deletions src/Facades/ShortURL.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace AshAllenDesign\ShortURL\Facades;

use AshAllenDesign\ShortURL\Classes\Builder;
use Illuminate\Support\Facades\Facade;
use RuntimeException;

/**
* @method static self destinationUrl(string $url)
* @method static self singleUse(bool $isSingleUse = true)
* @method static self secure(bool $isSecure = true)
* @method static self trackVisits(bool $trackVisits = true)
* @method static self trackIPAddress(bool $track)
* @method static self trackOperatingSystem(bool $track)
* @method static self trackOperatingSystemVersion(bool $track)
* @method static self trackBrowser(bool $track)
* @method static self trackBrowserVersion(bool $track)
* @method static self trackRefererURL(bool $track)
* @method static self trackDeviceType(bool $track)
* @method static self urlKey(string $key)
* @method static self redirectStatusCode(int $statusCode)
* @method static self resetOptions()
* @method static \AshAllenDesign\ShortURL\Models\ShortURL make()
*
* @see Builder
*/
class ShortURL extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*
* @throws RuntimeException
*/
protected static function getFacadeAccessor(): string
{
return 'short-url.builder';
}
}
2 changes: 2 additions & 0 deletions src/Facades/ShortURLBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Classes/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -32,6 +33,7 @@ protected function getPackageAliases($app)
{
return [
'ShortURLBuilder' => ShortURLBuilder::class,
'ShortURL' => ShortURL::class,
];
}

Expand Down