Skip to content

Commit 2f9026f

Browse files
authored
Apply fixes from StyleCI (#348)
1 parent 3cbcf7a commit 2f9026f

File tree

8 files changed

+25
-29
lines changed

8 files changed

+25
-29
lines changed

src/LaravelRestifyServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function registerPublishing()
8484
$migrationFileName = 'create_action_logs_table.php';
8585
if (! $this->migrationFileExists($migrationFileName)) {
8686
$this->publishes([
87-
__DIR__ . "/../database/migrations/{$migrationFileName}" => database_path('migrations/' . date('Y_m_d_His', time()) . '_' . $migrationFileName),
87+
__DIR__."/../database/migrations/{$migrationFileName}" => database_path('migrations/'.date('Y_m_d_His', time()).'_'.$migrationFileName),
8888
], 'restify-migrations');
8989
}
9090

@@ -98,7 +98,7 @@ protected function registerPublishing()
9898
public static function migrationFileExists(string $migrationFileName): bool
9999
{
100100
$len = strlen($migrationFileName);
101-
foreach (glob(database_path("migrations/*.php")) as $filename) {
101+
foreach (glob(database_path('migrations/*.php')) as $filename) {
102102
if ((substr($filename, -$len) === $migrationFileName)) {
103103
return true;
104104
}

src/Models/ActionLog.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Support\Str;
88

99
/**
10-
* Class ActionLog
10+
* Class ActionLog.
1111
* @property string batch_id
1212
* @property string user_id
1313
* @property string name
@@ -22,7 +22,6 @@
2222
* @property string original
2323
* @property string changes
2424
* @property string exception
25-
* @package Binaryk\LaravelRestify\Models
2625
*/
2726
class ActionLog extends Model
2827
{
@@ -44,7 +43,7 @@ class ActionLog extends Model
4443
public static function forRepositoryStored(Model $model, Authenticatable $user = null, array $dirty = null): self
4544
{
4645
return new static([
47-
'batch_id' => (string)Str::uuid(),
46+
'batch_id' => (string) Str::uuid(),
4847
'user_id' => optional($user)->getAuthIdentifier(),
4948
'name' => static::ACTION_CREATED,
5049
'actionable_type' => $model->getMorphClass(),
@@ -66,7 +65,7 @@ public static function forRepositoryStored(Model $model, Authenticatable $user =
6665
public static function forRepositoryUpdated(Model $model, Authenticatable $user = null): self
6766
{
6867
return new static([
69-
'batch_id' => (string)Str::uuid(),
68+
'batch_id' => (string) Str::uuid(),
7069
'user_id' => optional($user)->getAuthIdentifier(),
7170
'name' => static::ACTION_UPDATED,
7271
'actionable_type' => $model->getMorphClass(),
@@ -88,7 +87,7 @@ public static function forRepositoryUpdated(Model $model, Authenticatable $user
8887
public static function forRepositoryDestroy(Model $model, Authenticatable $user = null): self
8988
{
9089
return new static([
91-
'batch_id' => (string)Str::uuid(),
90+
'batch_id' => (string) Str::uuid(),
9291
'user_id' => optional($user)->getAuthIdentifier(),
9392
'name' => static::ACTION_DELETED,
9493
'actionable_type' => $model->getMorphClass(),

src/Repositories/ActionLogRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function fields(RestifyRequest $request)
1414
return [
1515
field('actionable_type'),
1616

17-
field('actionable_id')
17+
field('actionable_id'),
1818
];
1919
}
2020
}

src/Repositories/Repository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,6 @@ public function detach(RestifyRequest $request, $repositoryId, Collection $pivot
842842
public function destroy(RestifyRequest $request, $repositoryId)
843843
{
844844
$status = DB::transaction(function () use ($request) {
845-
846845
if ($this->resource instanceof ActionLogable) {
847846
Restify::actionLog()
848847
->forRepositoryDestroy($this->resource, $request->user())

src/Services/Concerns/ResetsPasswords.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected function sendResetResponse($response)
148148
protected function sendResetFailedResponse(Request $request, $response)
149149
{
150150
return response()->json(['email' => [
151-
trans($response)
151+
trans($response),
152152
]])->setStatusCode(400);
153153
}
154154

src/Services/ForgotPasswordService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ protected function sendResetLinkFailedResponse(Request $request, $response)
7272
return response()->json([
7373
'errors' => [
7474
'email' => [
75-
trans($response)
76-
]
77-
]
75+
trans($response),
76+
],
77+
],
7878
])->setStatusCode(400);
7979
}
8080
}

tests/Controllers/RepositoryUpdateControllerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function test_basic_update_works()
2323
{
2424
$post = factory(Post::class)->create();
2525

26-
$this->patch('posts/' . $post->id, [
26+
$this->patch('posts/'.$post->id, [
2727
'title' => 'Updated title',
2828
])->assertStatus(200);
2929

@@ -34,7 +34,7 @@ public function test_put_works()
3434
{
3535
$post = factory(Post::class)->create();
3636

37-
$this->withoutExceptionHandling()->put('posts/' . $post->id, [
37+
$this->withoutExceptionHandling()->put('posts/'.$post->id, [
3838
'title' => 'Updated title',
3939
])->assertStatus(200);
4040

@@ -51,7 +51,7 @@ public function test_unathorized_to_update()
5151

5252
$_SERVER['restify.post.update'] = false;
5353

54-
$this->patch('posts/' . $post->id, [
54+
$this->patch('posts/'.$post->id, [
5555
'title' => 'Updated title',
5656
])->assertStatus(403)
5757
->assertJson([
@@ -65,7 +65,7 @@ public function test_do_not_update_fields_without_permission()
6565

6666
$_SERVER['posts.authorizable.title'] = false;
6767

68-
$response = $this->putJson('post-with-unathorized-fields/' . $post->id, [
68+
$response = $this->putJson('post-with-unathorized-fields/'.$post->id, [
6969
'title' => 'Updated title',
7070
'user_id' => 2,
7171
])
@@ -81,7 +81,7 @@ public function test_will_not_update_readonly_fields()
8181

8282
$post = factory(Post::class)->create(['image' => null]);
8383

84-
$r = $this->putJson('posts-unauthorized-fields/' . $post->id, [
84+
$r = $this->putJson('posts-unauthorized-fields/'.$post->id, [
8585
'user_id' => $user->id,
8686
'image' => 'avatar.png',
8787
'title' => 'Some post title',
@@ -108,7 +108,7 @@ public function test_updating_repository_log_action()
108108
'user_id' => $this->authenticatedAs->getAuthIdentifier(),
109109
'name' => ActionLog::ACTION_UPDATED,
110110
'actionable_type' => Post::class,
111-
'actionable_id' => (string)$post->id
111+
'actionable_id' => (string) $post->id,
112112
]);
113113

114114
$log = ActionLog::latest()->first();

tests/IntegrationTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function setUp(): void
5252
$this->repositoryMock();
5353
$this->loadMigrations();
5454
$this->loadRoutes();
55-
$this->withFactories(__DIR__ . '/Factories');
55+
$this->withFactories(__DIR__.'/Factories');
5656
$this->injectTranslator();
5757
$this->app->bind(ExceptionHandler::class, RestifyHandler::class);
5858

@@ -87,7 +87,7 @@ protected function getEnvironmentSetUp($app)
8787
'prefix' => '',
8888
]);
8989

90-
include_once __DIR__ . '/../database/migrations/create_action_logs_table.php';
90+
include_once __DIR__.'/../database/migrations/create_action_logs_table.php';
9191
(new \CreateActionLogsTable())->up();
9292
}
9393

@@ -100,7 +100,7 @@ protected function loadMigrations()
100100
{
101101
$this->loadMigrationsFrom([
102102
'--database' => 'sqlite',
103-
'--path' => realpath(__DIR__ . DIRECTORY_SEPARATOR . 'Migrations'),
103+
'--path' => realpath(__DIR__.DIRECTORY_SEPARATOR.'Migrations'),
104104
]);
105105
}
106106

@@ -237,7 +237,7 @@ public function mockUsers($count = 1, $predefinedEmails = [])
237237
$i = 0;
238238
while ($i < $count) {
239239
$users->push(factory(User::class)->create());
240-
$i ++;
240+
$i++;
241241
}
242242

243243
foreach ($predefinedEmails as $email) {
@@ -262,31 +262,29 @@ public function mockPosts($userId, $count = 1)
262262
$users->push(factory(Post::class)->create(
263263
['user_id' => $userId]
264264
));
265-
$i ++;
265+
$i++;
266266
}
267267

268268
return $users->shuffle(); // randomly shuffles the items in the collection
269269
}
270270

271271
public function getTempDirectory($suffix = ''): string
272272
{
273-
return __DIR__ . '/TestSupport/temp' . ($suffix == '' ? '' : '/' . $suffix);
273+
return __DIR__.'/TestSupport/temp'.($suffix == '' ? '' : '/'.$suffix);
274274
}
275275

276276
public function getMediaDirectory($suffix = ''): string
277277
{
278-
return $this->getTempDirectory() . '/media' . ($suffix == '' ? '' : '/' . $suffix);
278+
return $this->getTempDirectory().'/media'.($suffix == '' ? '' : '/'.$suffix);
279279
}
280280

281281
public function getTestFilesDirectory($suffix = ''): string
282282
{
283-
return $this->getTempDirectory() . '/testfiles' . ($suffix == '' ? '' : '/' . $suffix);
283+
return $this->getTempDirectory().'/testfiles'.($suffix == '' ? '' : '/'.$suffix);
284284
}
285285

286286
public function getTestJpg(): string
287287
{
288288
return $this->getTestFilesDirectory('test.jpg');
289289
}
290-
291-
292290
}

0 commit comments

Comments
 (0)