Skip to content

Commit

Permalink
Apply fixes from StyleCI (#1)
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
zbiller committed Jun 3, 2019
1 parent 20b3ae9 commit f382b0c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config/redirects.php
Expand Up @@ -30,4 +30,4 @@
*/
'redirect_model' => \Neurony\Redirects\Models\Redirect::class,

];
];
6 changes: 3 additions & 3 deletions src/Contracts/RedirectModelContract.php
Expand Up @@ -38,11 +38,11 @@ public static function getStatuses() : array;
* @param string $finalUrl
* @return void
*/
public function syncOldRedirects(RedirectModelContract $model, string $finalUrl): void;
public function syncOldRedirects(self $model, string $finalUrl): void;

/**
* @param string $path
* @return RedirectModelContract|null
*/
public static function findValidOrNull($path): RedirectModelContract;
}
public static function findValidOrNull($path): self;
}
2 changes: 1 addition & 1 deletion src/Exceptions/RedirectException.php
Expand Up @@ -15,4 +15,4 @@ public static function sameUrls()
{
return new static('The old url cannot be the same as the new url!');
}
}
}
6 changes: 3 additions & 3 deletions src/Middleware/RedirectRequests.php
Expand Up @@ -17,8 +17,8 @@ public function handle($request, Closure $next)
{
$redirect = app('redirect.model')->findValidOrNull($request->path());

if (!$redirect && $request->getQueryString()) {
$path = $request->path() . '?' . $request->getQueryString();
if (! $redirect && $request->getQueryString()) {
$path = $request->path().'?'.$request->getQueryString();
$redirect = app('redirect.model')->findValidOrNull($path);
}

Expand All @@ -28,4 +28,4 @@ public function handle($request, Closure $next)

return $next($request);
}
}
}
12 changes: 6 additions & 6 deletions src/Models/Redirect.php
Expand Up @@ -2,10 +2,10 @@

namespace Neurony\Redirects\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Neurony\Redirects\Contracts\RedirectModelContract;
use Illuminate\Database\Eloquent\Builder;
use Neurony\Redirects\Exceptions\RedirectException;
use Neurony\Redirects\Contracts\RedirectModelContract;

class Redirect extends Model implements RedirectModelContract
{
Expand Down Expand Up @@ -100,7 +100,7 @@ public function scopeWhereNewUrl($query, string $url)
*/
public static function getStatuses(): array
{
return (array)config('redirects.statuses', []);
return (array) config('redirects.statuses', []);
}

/**
Expand All @@ -113,7 +113,7 @@ public static function getStatuses(): array
public function syncOldRedirects(RedirectModelContract $model, string $finalUrl): void
{
$items = static::whereNewUrl($model->old_url)->get();

foreach ($items as $item) {
$item->update(['new_url' => $finalUrl]);
$item->syncOldRedirects($model, $finalUrl);
Expand All @@ -124,7 +124,7 @@ public function syncOldRedirects(RedirectModelContract $model, string $finalUrl)
* Return a valid redirect entity for a given path (old url).
* A redirect is valid if:
* - it has an url to redirect to (new url)
* - it's status code is one of the statuses defined on this model
* - it's status code is one of the statuses defined on this model.
*
* @param string $path
* @return Redirect|null
Expand All @@ -136,4 +136,4 @@ public static function findValidOrNull($path): RedirectModelContract
->whereIn('status', array_keys(self::getStatuses()))
->latest()->first();
}
}
}
4 changes: 2 additions & 2 deletions src/ServiceProvider.php
Expand Up @@ -4,10 +4,10 @@

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Route;
use Neurony\Redirects\Contracts\RedirectModelContract;
use Neurony\Redirects\Middleware\RedirectRequests;
use Neurony\Redirects\Models\Redirect;
use Illuminate\Contracts\Foundation\Application;
use Neurony\Redirects\Middleware\RedirectRequests;
use Neurony\Redirects\Contracts\RedirectModelContract;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

class ServiceProvider extends BaseServiceProvider
Expand Down
2 changes: 1 addition & 1 deletion tests/RedirectTest.php
Expand Up @@ -2,8 +2,8 @@

namespace Neurony\Redirects\Tests;

use Neurony\Redirects\Exceptions\RedirectException;
use Neurony\Redirects\Models\Redirect;
use Neurony\Redirects\Exceptions\RedirectException;

class RedirectTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ServiceProvider.php
Expand Up @@ -2,9 +2,9 @@

namespace Neurony\Redirects\Tests;

use Neurony\Redirects\Contracts\RedirectModelContract;
use Neurony\Redirects\Models\Redirect;
use Illuminate\Contracts\Foundation\Application;
use Neurony\Redirects\Contracts\RedirectModelContract;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

class ServiceProvider extends BaseServiceProvider
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Expand Up @@ -3,9 +3,9 @@
namespace Neurony\Redirects\Tests;

use Illuminate\Contracts\Http\Kernel;
use Neurony\Redirects\Middleware\RedirectRequests;
use Orchestra\Testbench\TestCase as Orchestra;
use Illuminate\Contracts\Foundation\Application;
use Neurony\Redirects\Middleware\RedirectRequests;

abstract class TestCase extends Orchestra
{
Expand Down

0 comments on commit f382b0c

Please sign in to comment.