diff --git a/.php_cs b/.php_cs index c02e074..a6586b7 100644 --- a/.php_cs +++ b/.php_cs @@ -9,6 +9,7 @@ $config = PhpCsFixer\Config::create() '@PSR2' => true, '@PhpCsFixer' => true, 'list_syntax' => ['syntax' => 'long'], + 'multiline_whitespace_before_semicolons' => false, ]) ->setFinder($finder) ; diff --git a/config/config.php b/config/config.php index 47c915b..acfde4c 100644 --- a/config/config.php +++ b/config/config.php @@ -1,7 +1,6 @@ [ 'name' => '/^(route-usage|nova|debugbar|horizon)\./', - 'uri' => '' + 'uri' => '', ], - ]; diff --git a/src/Authorize.php b/src/Authorize.php index 20a60d0..dc201c8 100644 --- a/src/Authorize.php +++ b/src/Authorize.php @@ -2,7 +2,6 @@ namespace Julienbourdeau\RouteUsage; - use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Gate; diff --git a/src/Console/Commands/UsageRouteCommand.php b/src/Console/Commands/UsageRouteCommand.php index 7488976..a1837b8 100644 --- a/src/Console/Commands/UsageRouteCommand.php +++ b/src/Console/Commands/UsageRouteCommand.php @@ -30,7 +30,7 @@ protected function getRoutes() } return true; - }); + }); // TODO: sort by updated_at and group by method+path $routeUsage = RouteUsage::all()->mapWithKeys(function ($r) { diff --git a/src/Listeners/LogRouteUsage.php b/src/Listeners/LogRouteUsage.php index badfa88..fb341fe 100644 --- a/src/Listeners/LogRouteUsage.php +++ b/src/Listeners/LogRouteUsage.php @@ -2,7 +2,6 @@ namespace Julienbourdeau\RouteUsage\Listeners; -use Illuminate\Support\Facades\DB; use Julienbourdeau\RouteUsage\RouteUsage; class LogRouteUsage @@ -16,13 +15,13 @@ public function handle($event) extract($this->extractAttributes($event)); RouteUsage::updateOrCreate([ - 'identifier' => $identifier + 'identifier' => $identifier, ], [ 'method' => $method, 'path' => $path, 'status_code' => $status_code, 'action' => $action, - 'updated_at' => $date + 'updated_at' => $date, ]); } @@ -61,6 +60,7 @@ protected function extractAttributes($event) } elseif (!is_string($action) && !is_null($action)) { $action = '[Unsupported]'; } + return [ 'status_code' => $status_code = $event->response->getStatusCode(), 'method' => $method = $event->request->getMethod(), diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 3328f67..31140fb 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -41,7 +41,6 @@ public function itCanCreateRouteUsageEntry() /** @test */ public function itSavesRouteUsageEntryIfResponseIsValid() { - $response = $this->get('/'); $response->assertStatus(200); $this->assertEquals(1, RouteUsage::count()); @@ -56,7 +55,7 @@ public function itSavesRouteUsageEntryIfResponseIsValid() public function itUpdatesUpdatedatAttribute() { RouteUsage::create([ - 'identifier' => ($id = sha1('GET' . '/' . '[Closure]' . '200')), + 'identifier' => ($id = sha1('GET'.'/'.'[Closure]'.'200')), 'method' => 'GET', 'path' => '/', 'status_code' => 200, @@ -87,8 +86,8 @@ public function itIgnoresRoutesBasedOnConfig() config(['route-usage' => [ 'excluding-regex' => [ 'name' => '/^nope\./', - 'uri' => '/ignore/' - ] + 'uri' => '/ignore/', + ], ]]); Route::get('/ok', function () { return 'OK'; })->name('nope.index'); Route::get('/ignore', function () { return 'KO'; }); @@ -104,7 +103,6 @@ public function itIgnoresRoutesBasedOnConfig() /** @test */ public function itOnlyShowsHtmlPageOnLocalByDefault() { - $response = $this->get(route('route-usage.index')); $response->assertStatus(403);