Skip to content

Commit 0c53695

Browse files
SlimGeegithub-actions[bot]
authored andcommitted
Fix styling
1 parent 957a8cd commit 0c53695

File tree

4 files changed

+14
-50
lines changed

4 files changed

+14
-50
lines changed

src/Commands/GeneratePermissionsCommand.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class GeneratePermissionsCommand extends Command
2727

2828
/**
2929
* Run the command.
30-
*
31-
* @return int
3230
*/
3331
public function handle(): int
3432
{
@@ -49,8 +47,6 @@ public function handle(): int
4947

5048
/**
5149
* Generate all permissions.
52-
*
53-
* @return void
5450
*/
5551
protected function generatePermissionsForAllModels(): void
5652
{
@@ -61,9 +57,6 @@ protected function generatePermissionsForAllModels(): void
6157

6258
/**
6359
* Generate permission for a given model.
64-
*
65-
* @param string $model
66-
* @return void
6760
*/
6861
public function generatePermissions(string $model): void
6962
{

src/Commands/LaravelAuthorizerCommand.php

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class LaravelAuthorizerCommand extends Command
2727

2828
/**
2929
* Run the command.
30-
*
31-
* @return int
3230
*/
3331
public function handle(): int
3432
{
@@ -60,27 +58,22 @@ public function handle(): int
6058

6159
/**
6260
* Generate policies for all models.
63-
*
64-
* @return void
6561
*/
6662
public function generateAllPolicies(): void
6763
{
6864
$this->getModels()->each(
69-
fn(string $model) => $this->generatePolicy($model, $model)
65+
fn (string $model) => $this->generatePolicy($model, $model)
7066
);
7167
}
7268

7369
/**
7470
* Generate a plain policy without a model.
75-
*
76-
* @param string $name
77-
* @return void
7871
*/
7972
public function generatePlainPolicy(string $name): void
8073
{
8174
if (
8275
file_exists($this->getPolicyPath($name)) &&
83-
!$this->option('force')
76+
! $this->option('force')
8477
) {
8578
$this->error(sprintf('Policy "%s" already exists!', $name));
8679

@@ -92,8 +85,8 @@ public function generatePlainPolicy(string $name): void
9285
'namespace' => $this->getNamespace(),
9386
'class' => $this->getClassName($name),
9487
])->reduce(
95-
fn($carry, $value, $key) => Str::replace(
96-
'{{ ' . $key . ' }}',
88+
fn ($carry, $value, $key) => Str::replace(
89+
'{{ '.$key.' }}',
9790
$value,
9891
$carry
9992
)
@@ -104,16 +97,12 @@ public function generatePlainPolicy(string $name): void
10497

10598
/**
10699
* Generate a policy for a given model.
107-
*
108-
* @param string $name
109-
* @param string $model
110-
* @return void
111100
*/
112101
private function generatePolicy(string $name, string $model): void
113102
{
114103
if (
115104
file_exists($this->getPolicyPath($name)) &&
116-
!$this->option('force')
105+
! $this->option('force')
117106
) {
118107
$this->error(sprintf('Policy "%s" already exists!', $name));
119108

@@ -123,8 +112,7 @@ private function generatePolicy(string $name, string $model): void
123112
$compiled = collect([
124113
'name' => $name,
125114
'model' => $model,
126-
'modelVariable' =>
127-
strtolower($model) ===
115+
'modelVariable' => strtolower($model) ===
128116
strtolower(
129117
Str::afterLast($this->getNamespacedUserModel(), '\\')
130118
)
@@ -138,8 +126,8 @@ private function generatePolicy(string $name, string $model): void
138126
'namespacedUserModel' => $this->getNamespacedUserModel(),
139127
'user' => Str::afterLast($this->getNamespacedUserModel(), '\\'),
140128
])->reduce(
141-
static fn($old, $value, $key) => Str::replace(
142-
'{{ ' . $key . ' }}',
129+
static fn ($old, $value, $key) => Str::replace(
130+
'{{ '.$key.' }}',
143131
$value,
144132
$old
145133
),
@@ -158,55 +146,46 @@ private function generatePolicy(string $name, string $model): void
158146

159147
/**
160148
* Get the path to the policy.
161-
*
162-
* @param string $name
163-
* @return string
164149
*/
165150
public function getPolicyPath(string $name): string
166151
{
167-
return app_path('Policies/' . $this->getClassName($name) . '.php');
152+
return app_path('Policies/'.$this->getClassName($name).'.php');
168153
}
169154

170155
/**
171156
* Get the policies' namespace.
172-
*
173-
* @return string
174157
*/
175158
public function getNamespace(): string
176159
{
177-
return app()->getNamespace() . 'Policies';
160+
return app()->getNamespace().'Policies';
178161
}
179162

180163
/**
181164
* Get the class name for the policy.
182165
*
183166
* @param string $name The name of the policy
184-
* @return string
185167
*/
186168
public function getClassName(string $name): string
187169
{
188170
if (Str::endsWith(Str::lower($name), 'policy')) {
189171
return Str::studly($name);
190172
}
191173

192-
return Str::studly($name) . 'Policy';
174+
return Str::studly($name).'Policy';
193175
}
194176

195177
/**
196178
* Get the namespace for the model.
197179
*
198180
* @param string $model The name of the model
199-
* @return string
200181
*/
201182
public function getNamespacedModel(string $model): string
202183
{
203-
return app()->getNamespace() . 'Models\\' . Str::studly($model);
184+
return app()->getNamespace().'Models\\'.Str::studly($model);
204185
}
205186

206187
/**
207188
* Get the namespace for the User model.
208-
*
209-
* @return string
210189
*/
211190
public function getNamespacedUserModel(): string
212191
{
@@ -215,21 +194,17 @@ public function getNamespacedUserModel(): string
215194

216195
/**
217196
* Get the path to the stub.
218-
*
219-
* @return string
220197
*/
221198
public function getStub(): string
222199
{
223-
return __DIR__ . '/stubs/policy.stub';
200+
return __DIR__.'/stubs/policy.stub';
224201
}
225202

226203
/**
227204
* Get the path to the user policy stub
228-
*
229-
* @return string
230205
*/
231206
public function getUserPolicyPolicyStub(): string
232207
{
233-
return __DIR__ . '/stubs/policy.user.stub';
208+
return __DIR__.'/stubs/policy.user.stub';
234209
}
235210
}

src/Commands/SetupCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class SetupCommand extends Command
2323

2424
/**
2525
* Execute the console command.
26-
*
27-
* @return int
2826
*/
2927
public function handle(): int
3028
{

src/Commands/Traits/LocatesModels.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ trait LocatesModels
1414
{
1515
/**
1616
* Get all models.
17-
*
18-
* @return Collection
1917
*/
2018
protected function getModels(): Collection
2119
{

0 commit comments

Comments
 (0)