11<?php
22
3+ declare (strict_types=1 );
4+
35namespace ApiSkeletons \Laravel \Doctrine \ApiKey \Console \Command ;
46
57use ApiSkeletons \Laravel \Doctrine \ApiKey \Entity \ApiKey ;
68use ApiSkeletons \Laravel \Doctrine \ApiKey \Entity \Scope ;
79use ApiSkeletons \Laravel \Doctrine \ApiKey \Exception \DuplicateScopeForApiKey ;
8- use ApiSkeletons \Laravel \Doctrine \ApiKey \Exception \ScopeHasApiKeys ;
910use ApiSkeletons \Laravel \Doctrine \ApiKey \Service \ApiKeyService ;
1011use Illuminate \Console \Command ;
1112
13+ use function implode ;
14+
1215final 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
0 commit comments