Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
julienbourdeau committed Dec 7, 2019
1 parent 6c2a2fc commit 155867d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $config = PhpCsFixer\Config::create()
'@PSR2' => true,
'@PhpCsFixer' => true,
'list_syntax' => ['syntax' => 'long'],
'multiline_whitespace_before_semicolons' => false,
])
->setFinder($finder)
;
Expand Down
4 changes: 1 addition & 3 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Exclude requests based on route name or uri
Expand All @@ -16,7 +15,6 @@

'excluding-regex' => [
'name' => '/^(route-usage|nova|debugbar|horizon)\./',
'uri' => ''
'uri' => '',
],

];
1 change: 0 additions & 1 deletion src/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Julienbourdeau\RouteUsage;


use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Gate;

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/UsageRouteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/Listeners/LogRouteUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Julienbourdeau\RouteUsage\Listeners;

use Illuminate\Support\Facades\DB;
use Julienbourdeau\RouteUsage\RouteUsage;

class LogRouteUsage
Expand All @@ -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,
]);
}

Expand Down Expand Up @@ -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(),
Expand Down
8 changes: 3 additions & 5 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function itCanCreateRouteUsageEntry()
/** @test */
public function itSavesRouteUsageEntryIfResponseIsValid()
{

$response = $this->get('/');
$response->assertStatus(200);
$this->assertEquals(1, RouteUsage::count());
Expand All @@ -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,
Expand Down Expand Up @@ -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'; });
Expand All @@ -104,7 +103,6 @@ public function itIgnoresRoutesBasedOnConfig()
/** @test */
public function itOnlyShowsHtmlPageOnLocalByDefault()
{

$response = $this->get(route('route-usage.index'));
$response->assertStatus(403);

Expand Down

0 comments on commit 155867d

Please sign in to comment.