Skip to content

Commit d78da21

Browse files
committed
phpcs
1 parent de28c14 commit d78da21

18 files changed

+191
-225
lines changed

src/Console/Command/ActivateApiKey.php

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ApiSkeletons\Laravel\Doctrine\ApiKey\Console\Command;
46

57
use ApiSkeletons\Laravel\Doctrine\ApiKey\Entity\ApiKey;
6-
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\DuplicateName;
7-
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\InvalidName;
88
use ApiSkeletons\Laravel\Doctrine\ApiKey\Service\ApiKeyService;
99
use Illuminate\Console\Command;
1010

11+
use function implode;
12+
1113
final class ActivateApiKey extends Command
1214
{
1315
private ApiKeyService $apiKeyService;
1416

1517
/**
1618
* The name and signature of the console command.
17-
*
18-
* @var string
1919
*/
20-
protected $signature = 'apikey:activate {name}';
20+
protected string $signature = 'apikey:activate {name}';
2121

2222
/**
2323
* The console command description.
24-
*
25-
* @var string
2624
*/
27-
protected $description = 'Activate an ApiKey';
25+
protected string $description = 'Activate an ApiKey';
2826

2927
/**
3028
* Create a new command instance.
@@ -40,19 +38,15 @@ public function __construct(ApiKeyService $apiKeyService)
4038

4139
/**
4240
* Execute the console command.
43-
*
44-
* @return mixed
4541
*/
46-
public function handle()
42+
public function handle(): mixed
4743
{
4844
$name = $this->argument('name');
4945

5046
$apiKeyRepository = $this->apiKeyService->getEntityManager()
5147
->getRepository(ApiKey::class);
5248

53-
$apiKey = $apiKeyRepository->findOneBy([
54-
'name' => $name,
55-
]);
49+
$apiKey = $apiKeyRepository->findOneBy(['name' => $name]);
5650

5751
if (! $apiKey) {
5852
$this->error('Invalid apiKey name');
@@ -69,12 +63,14 @@ public function handle()
6963
}
7064

7165
$headers = ['name', 'key', 'status', 'scopes'];
72-
$rows = [[
73-
$apiKey->getName(),
74-
$apiKey->getKey(),
75-
$apiKey->getIsActive() ? 'active': 'deactivated',
76-
implode(',', $scopeNames)
77-
]];
66+
$rows = [
67+
[
68+
$apiKey->getName(),
69+
$apiKey->getKey(),
70+
$apiKey->getIsActive() ? 'active' : 'deactivated',
71+
implode(',', $scopeNames),
72+
],
73+
];
7874

7975
$this->table($headers, $rows);
8076

src/Console/Command/AddScope.php

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ApiSkeletons\Laravel\Doctrine\ApiKey\Console\Command;
46

57
use ApiSkeletons\Laravel\Doctrine\ApiKey\Entity\ApiKey;
68
use ApiSkeletons\Laravel\Doctrine\ApiKey\Entity\Scope;
79
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\DuplicateScopeForApiKey;
8-
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\ScopeHasApiKeys;
910
use ApiSkeletons\Laravel\Doctrine\ApiKey\Service\ApiKeyService;
1011
use Illuminate\Console\Command;
1112

13+
use function implode;
14+
1215
final class AddScope extends Command
1316
{
1417
private ApiKeyService $apiKeyService;
1518

1619
/**
1720
* The name and signature of the console command.
18-
*
19-
* @var string
2021
*/
21-
protected $signature = 'apikey:scope:add {apiKeyName} {scopeName}';
22+
protected string $signature = 'apikey:scope:add {apiKeyName} {scopeName}';
2223

2324
/**
2425
* The console command description.
25-
*
26-
* @var string
2726
*/
28-
protected $description = 'Add a Scope to an ApiKey';
27+
protected string $description = 'Add a Scope to an ApiKey';
2928

3029
/**
3130
* Create a new command instance.
@@ -41,31 +40,25 @@ public function __construct(ApiKeyService $apiKeyService)
4140

4241
/**
4342
* Execute the console command.
44-
*
45-
* @return mixed
4643
*/
47-
public function handle()
44+
public function handle(): mixed
4845
{
4946
$apiKeyName = $this->argument('apiKeyName');
50-
$scopeName = $this->argument('scopeName');
47+
$scopeName = $this->argument('scopeName');
5148

5249
$apiKeyRepository = $this->apiKeyService->getEntityManager()
5350
->getRepository(ApiKey::class);
54-
$scopeRepository = $this->apiKeyService->getEntityManager()
51+
$scopeRepository = $this->apiKeyService->getEntityManager()
5552
->getRepository(Scope::class);
5653

57-
$apiKey = $apiKeyRepository->findOneBy([
58-
'name' => $apiKeyName,
59-
]);
54+
$apiKey = $apiKeyRepository->findOneBy(['name' => $apiKeyName]);
6055
if (! $apiKey) {
6156
$this->error('Cannot find ApiKey with name: ' . $apiKeyName);
6257

6358
return 1;
6459
}
6560

66-
$scope = $scopeRepository->findOneBy([
67-
'name' => $scopeName,
68-
]);
61+
$scope = $scopeRepository->findOneBy(['name' => $scopeName]);
6962
if (! $scope) {
7063
$this->error('Cannot find scope with name: ' . $scopeName);
7164

@@ -87,12 +80,14 @@ public function handle()
8780
}
8881

8982
$headers = ['name', 'key', 'status', 'scopes'];
90-
$rows = [[
91-
$apiKey->getName(),
92-
$apiKey->getKey(),
93-
$apiKey->getIsActive() ? 'active': 'deactivated',
94-
implode(',', $scopeNames)
95-
]];
83+
$rows = [
84+
[
85+
$apiKey->getName(),
86+
$apiKey->getKey(),
87+
$apiKey->getIsActive() ? 'active' : 'deactivated',
88+
implode(',', $scopeNames),
89+
],
90+
];
9691

9792
$this->table($headers, $rows);
9893

src/Console/Command/DeactivateApiKey.php

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ApiSkeletons\Laravel\Doctrine\ApiKey\Console\Command;
46

57
use ApiSkeletons\Laravel\Doctrine\ApiKey\Entity\ApiKey;
6-
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\DuplicateName;
7-
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\InvalidName;
88
use ApiSkeletons\Laravel\Doctrine\ApiKey\Service\ApiKeyService;
99
use Illuminate\Console\Command;
1010

11+
use function implode;
12+
1113
final class DeactivateApiKey extends Command
1214
{
1315
private ApiKeyService $apiKeyService;
1416

1517
/**
1618
* The name and signature of the console command.
17-
*
18-
* @var string
1919
*/
20-
protected $signature = 'apikey:deactivate {name}';
20+
protected string $signature = 'apikey:deactivate {name}';
2121

2222
/**
2323
* The console command description.
24-
*
25-
* @var string
2624
*/
27-
protected $description = 'Deactivate an ApiKey';
25+
protected string $description = 'Deactivate an ApiKey';
2826

2927
/**
3028
* Create a new command instance.
@@ -40,19 +38,15 @@ public function __construct(ApiKeyService $apiKeyService)
4038

4139
/**
4240
* Execute the console command.
43-
*
44-
* @return mixed
4541
*/
46-
public function handle()
42+
public function handle(): mixed
4743
{
4844
$name = $this->argument('name');
4945

5046
$apiKeyRepository = $this->apiKeyService->getEntityManager()
5147
->getRepository(ApiKey::class);
5248

53-
$apiKey = $apiKeyRepository->findOneBy([
54-
'name' => $name,
55-
]);
49+
$apiKey = $apiKeyRepository->findOneBy(['name' => $name]);
5650

5751
if (! $apiKey) {
5852
$this->error('Invalid apiKey name');
@@ -69,12 +63,14 @@ public function handle()
6963
}
7064

7165
$headers = ['name', 'key', 'status', 'scopes'];
72-
$rows = [[
73-
$apiKey->getName(),
74-
$apiKey->getKey(),
75-
$apiKey->getIsActive() ? 'active': 'deactivated',
76-
implode(',', $scopeNames)
77-
]];
66+
$rows = [
67+
[
68+
$apiKey->getName(),
69+
$apiKey->getKey(),
70+
$apiKey->getIsActive() ? 'active' : 'deactivated',
71+
implode(',', $scopeNames),
72+
],
73+
];
7874

7975
$this->table($headers, $rows);
8076

src/Console/Command/DeleteScope.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ApiSkeletons\Laravel\Doctrine\ApiKey\Console\Command;
46

57
use ApiSkeletons\Laravel\Doctrine\ApiKey\Entity\Scope;
6-
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\DuplicateName;
7-
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\InvalidName;
88
use ApiSkeletons\Laravel\Doctrine\ApiKey\Exception\ScopeHasApiKeys;
99
use ApiSkeletons\Laravel\Doctrine\ApiKey\Service\ApiKeyService;
1010
use Illuminate\Console\Command;
@@ -15,17 +15,13 @@ final class DeleteScope extends Command
1515

1616
/**
1717
* The name and signature of the console command.
18-
*
19-
* @var string
2018
*/
21-
protected $signature = 'apikey:scope:delete {name}';
19+
protected string $signature = 'apikey:scope:delete {name}';
2220

2321
/**
2422
* The console command description.
25-
*
26-
* @var string
2723
*/
28-
protected $description = 'Delete an ApiKey Scope (Delete a scope, not a relationship)';
24+
protected string $description = 'Delete an ApiKey Scope (Delete a scope, not a relationship)';
2925

3026
/**
3127
* Create a new command instance.
@@ -41,19 +37,15 @@ public function __construct(ApiKeyService $apiKeyService)
4137

4238
/**
4339
* Execute the console command.
44-
*
45-
* @return mixed
4640
*/
47-
public function handle()
41+
public function handle(): mixed
4842
{
4943
$name = $this->argument('name');
5044

5145
$scopeRepository = $this->apiKeyService->getEntityManager()
5246
->getRepository(Scope::class);
5347

54-
$scope = $scopeRepository->findOneBy([
55-
'name' => $name,
56-
]);
48+
$scope = $scopeRepository->findOneBy(['name' => $name]);
5749

5850
if (! $scope) {
5951
$this->error('Cannot find scope with name: ' . $name);

src/Console/Command/GenerateApiKey.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ApiSkeletons\Laravel\Doctrine\ApiKey\Console\Command;
46

57
use ApiSkeletons\Laravel\Doctrine\ApiKey\Entity\ApiKey;
@@ -8,23 +10,21 @@
810
use ApiSkeletons\Laravel\Doctrine\ApiKey\Service\ApiKeyService;
911
use Illuminate\Console\Command;
1012

13+
use function implode;
14+
1115
final class GenerateApiKey extends Command
1216
{
1317
private ApiKeyService $apiKeyService;
1418

1519
/**
1620
* The name and signature of the console command.
17-
*
18-
* @var string
1921
*/
20-
protected $signature = 'apikey:generate {name}';
22+
protected string $signature = 'apikey:generate {name}';
2123

2224
/**
2325
* The console command description.
24-
*
25-
* @var string
2626
*/
27-
protected $description = 'Create a new ApiKey';
27+
protected string $description = 'Create a new ApiKey';
2828

2929
/**
3030
* Create a new command instance.
@@ -40,10 +40,8 @@ public function __construct(ApiKeyService $apiKeyService)
4040

4141
/**
4242
* Execute the console command.
43-
*
44-
* @return mixed
4543
*/
46-
public function handle()
44+
public function handle(): mixed
4745
{
4846
$name = $this->argument('name');
4947

@@ -70,12 +68,14 @@ public function handle()
7068
}
7169

7270
$headers = ['name', 'key', 'status', 'scopes'];
73-
$rows = [[
74-
$apiKey->getName(),
75-
$apiKey->getKey(),
76-
$apiKey->getIsActive() ? 'active': 'deactivated',
77-
implode(',', $scopeNames)
78-
]];
71+
$rows = [
72+
[
73+
$apiKey->getName(),
74+
$apiKey->getKey(),
75+
$apiKey->getIsActive() ? 'active' : 'deactivated',
76+
implode(',', $scopeNames),
77+
],
78+
];
7979

8080
$this->table($headers, $rows);
8181

0 commit comments

Comments
 (0)