Skip to content

Commit 280365c

Browse files
committed
Apply fixes from StyleCI
1 parent 72d924e commit 280365c

File tree

12 files changed

+29
-33
lines changed

12 files changed

+29
-33
lines changed

src/Controls/Control.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Control
2424
public static $namespace = 'App\\Access\\Controls\\';
2525

2626
/**
27-
* Get the perimeters for the current control
27+
* Get the perimeters for the current control.
2828
*
2929
* @return array
3030
*/
@@ -36,21 +36,22 @@ protected function perimeters(): array
3636
/**
3737
* Specify the callback that should be invoked to guess control names.
3838
*
39-
* @param callable(class-string<\Illuminate\Database\Eloquent\Model>): class-string<\Lomkit\Access\Controls\Control> $callback
39+
* @param callable(class-string<\Illuminate\Database\Eloquent\Model>): class-string<\Lomkit\Access\Controls\Control> $callback
40+
*
4041
* @return void
4142
*/
4243
public static function guessControlNamesUsing(callable $callback)
4344
{
4445
static::$controlNameResolver = $callback;
4546
}
4647

47-
4848
/**
4949
* Get a new control instance for the given model name.
5050
*
5151
* @template TClass of \Illuminate\Database\Eloquent\Model
5252
*
53-
* @param class-string<TClass> $modelName
53+
* @param class-string<TClass> $modelName
54+
*
5455
* @return \Lomkit\Access\Controls\Control<TClass>
5556
*/
5657
public static function controlForModel(string $modelName)
@@ -69,15 +70,16 @@ public static function controlForModel(string $modelName)
6970
*/
7071
public static function new()
7172
{
72-
return (new static);
73+
return new static();
7374
}
7475

7576
/**
7677
* Get the control name for the given model name.
7778
*
7879
* @template TClass of \Illuminate\Database\Eloquent\Model
7980
*
80-
* @param class-string<TClass> $modelName
81+
* @param class-string<TClass> $modelName
82+
*
8183
* @return class-string<\Lomkit\Access\Controls\Control<TClass>>
8284
*/
8385
public static function resolveControlName(string $modelName)
@@ -110,4 +112,4 @@ protected static function appNamespace()
110112
return 'App\\';
111113
}
112114
}
113-
}
115+
}

src/Controls/HasControl.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace Lomkit\Access\Controls;
44

55
use Illuminate\Database\Eloquent\Factories\Factory;
6-
use Illuminate\Support\Facades\App;
7-
use Illuminate\Support\Str;
86

97
trait HasControl
108
{
@@ -15,7 +13,7 @@ trait HasControl
1513
*/
1614
public static function bootHasControl()
1715
{
18-
static::addGlobalScope(new HasControlScope);
16+
static::addGlobalScope(new HasControlScope());
1917
}
2018

2119
/**
@@ -39,4 +37,4 @@ protected static function newControl(): Control|null
3937
{
4038
return static::$control::new() ?? null;
4139
}
42-
}
40+
}

src/Perimeters/Perimeter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function query(Closure $queryCallback): self
2121
{
2222
// @TODO: ok mais pas possible de le déclarer globalement alors, seems ok for me
2323
$this->queryCallback = $queryCallback;
24+
2425
return $this;
2526
}
2627

@@ -31,6 +32,6 @@ public function query(Closure $queryCallback): self
3132
*/
3233
public static function new()
3334
{
34-
return (new static);
35+
return new static();
3536
}
36-
}
37+
}

tests/Feature/PerimetersTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,24 @@
22

33
namespace Lomkit\Access\Tests\Feature;
44

5-
use Illuminate\Database\Eloquent\Factories\Sequence;
65
use Illuminate\Support\Facades\Auth;
7-
use Illuminate\Support\Facades\Cache;
8-
use Lomkit\Access\Exceptions\QueryNotImplemented;
96
use Lomkit\Access\Tests\Support\Access\Perimeters\ClientPerimeter;
10-
use Lomkit\Access\Tests\Support\Database\Factories\ModelFactory;
117
use Lomkit\Access\Tests\Support\Models\Model;
12-
use Lomkit\Access\Tests\Support\Models\NotImplementedQueryModel;
13-
use Lomkit\Access\Tests\Support\Models\User;
148

159
class PerimetersTest extends TestCase
1610
{
1711
public function test_should_client_perimeter(): void
1812
{
1913
Auth::user()->update(['should_client' => true]);
2014

21-
$this->assertTrue((new ClientPerimeter())->should(Auth::user(), 'create', new Model));
15+
$this->assertTrue((new ClientPerimeter())->should(Auth::user(), 'create', new Model()));
2216
}
2317

2418
public function test_should_not_client_perimeter(): void
2519
{
2620
Auth::user()->update(['should_client' => false]);
2721

28-
$this->assertFalse((new ClientPerimeter())->should(Auth::user(), 'create', new Model));
22+
$this->assertFalse((new ClientPerimeter())->should(Auth::user(), 'create', new Model()));
2923
}
3024

3125
// @TODO: other perimeters

tests/Support/Access/Controls/ModelControl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ protected function perimeters(): array
2525
->query(function (Builder $query) {
2626
$query->where('is_own', true);
2727
}),
28-
];
28+
];
2929
}
30-
}
30+
}

tests/Support/Access/Perimeters/ClientPerimeter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public function should(Authenticatable $user, string $method, Model $model): boo
1212
{
1313
return $user->should_client;
1414
}
15-
}
15+
}

tests/Support/Access/Perimeters/GlobalPerimeter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public function should(Authenticatable $user, string $method, Model $model): boo
1212
{
1313
return $user->should_global;
1414
}
15-
}
15+
}

tests/Support/Access/Perimeters/OwnPerimeter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public function should(Authenticatable $user, string $method, Model $model): boo
1212
{
1313
return $user->should_own;
1414
}
15-
}
15+
}

tests/Support/Access/Perimeters/SharedPerimeter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public function should(Authenticatable $user, string $method, Model $model): boo
1212
{
1313
return $user->should_shared;
1414
}
15-
}
15+
}

tests/Support/Database/Factories/UserFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function definition(): array
3333
'remember_token' => Str::random(10),
3434
'should_shared' => false,
3535
'should_global' => false,
36-
'should_own' => false,
36+
'should_own' => false,
3737
'should_client' => false,
3838
];
3939
}

0 commit comments

Comments
 (0)