Skip to content

Commit 6effe03

Browse files
authored
Merge pull request #38 from Lomkit/analysis-wO2DBZ
Apply fixes from StyleCI
2 parents c315ff3 + 4b781f0 commit 6effe03

File tree

235 files changed

+2997
-3196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+2997
-3196
lines changed

config/rest.php

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414

1515
'automatic_gates' => [
1616
'enabled' => true,
17-
'key' => 'gates',
17+
'key' => 'gates',
1818
// Here you can customize the keys for each gate
1919
'names' => [
20-
'authorized_to_view' => 'authorized_to_view',
21-
'authorized_to_create' => 'authorized_to_create',
22-
'authorized_to_update' => 'authorized_to_update',
23-
'authorized_to_delete' => 'authorized_to_delete',
24-
'authorized_to_restore' => 'authorized_to_restore',
20+
'authorized_to_view' => 'authorized_to_view',
21+
'authorized_to_create' => 'authorized_to_create',
22+
'authorized_to_update' => 'authorized_to_update',
23+
'authorized_to_delete' => 'authorized_to_delete',
24+
'authorized_to_restore' => 'authorized_to_restore',
2525
'authorized_to_force_delete' => 'authorized_to_force_delete',
26-
]
26+
],
2727
],
2828

2929
/*
@@ -37,7 +37,7 @@
3737
*/
3838

3939
'authorizations' => [
40-
'enabled' => true
40+
'enabled' => true,
4141
],
4242

4343
/*
@@ -53,70 +53,70 @@
5353

5454
'documentation' => [
5555
'routing' => [
56-
'enabled' => true,
57-
'domain' => null,
58-
'path' => '/api-documentation',
56+
'enabled' => true,
57+
'domain' => null,
58+
'path' => '/api-documentation',
5959
'middlewares' => [
60-
'web'
61-
]
60+
'web',
61+
],
6262
],
6363
'info' => [
64-
'title' => config('app.name'),
65-
'summary' => 'This is my projet\'s documentation',
66-
'description' => 'Find out all about my projet\'s API',
64+
'title' => config('app.name'),
65+
'summary' => 'This is my projet\'s documentation',
66+
'description' => 'Find out all about my projet\'s API',
6767
'termsOfService' => null, // (Optional) Url to terms of services
68-
'contact' => [
69-
'name' => 'My Company',
68+
'contact' => [
69+
'name' => 'My Company',
7070
'email' => '[email protected]',
71-
'url' => 'https://company.com'
71+
'url' => 'https://company.com',
7272
],
7373
'license' => [
74-
'url' => null,
75-
'name' => 'Apache 2.0',
76-
'identifier' => 'Apache-2.0'
74+
'url' => null,
75+
'name' => 'Apache 2.0',
76+
'identifier' => 'Apache-2.0',
7777
],
78-
'version' => '1.0.0'
78+
'version' => '1.0.0',
7979
],
8080
// See https://spec.openapis.org/oas/v3.1.0#server-object
8181
'servers' => [
8282
[
83-
'url' => '/', // Relative to current
84-
'description' => 'The current server'
83+
'url' => '/', // Relative to current
84+
'description' => 'The current server',
8585
],
86-
// [
87-
// 'url' => '"https://my-server.com:{port}/{basePath}"',
88-
// 'description' => 'Production server',
89-
// 'variables' => [
90-
// 'port' => [
91-
// 'enum' => ['80', '443'],
92-
// 'default' => '443'
93-
// ],
94-
// 'basePath' => [
95-
// 'default' => 'v2',
96-
// 'enum' => ['v1', 'v2'],
97-
// ]
98-
// ]
99-
// ]
86+
// [
87+
// 'url' => '"https://my-server.com:{port}/{basePath}"',
88+
// 'description' => 'Production server',
89+
// 'variables' => [
90+
// 'port' => [
91+
// 'enum' => ['80', '443'],
92+
// 'default' => '443'
93+
// ],
94+
// 'basePath' => [
95+
// 'default' => 'v2',
96+
// 'enum' => ['v1', 'v2'],
97+
// ]
98+
// ]
99+
// ]
100100
],
101101
// See https://spec.openapis.org/oas/v3.1.0#security-scheme-object
102102
'security' => [
103-
// [
104-
// 'type' => 'http',
105-
// 'description' => 'description',
106-
// 'scheme' => 'Bearer',
107-
// 'bearerFormat' => 'JWT'
108-
// ],
109-
// [
110-
// 'type' => 'oauth2',
111-
// 'flows' => [
112-
// 'authorizationCode' => [
113-
// 'scopes' => ['write:pets'],
114-
// 'tokenUrl' => 'https://example.com/api/oauth/token',
115-
// 'authorizationUrl' => 'https://example.com/api/oauth/dialog',
116-
// 'refreshUrl' => 'https://example.com/api/oauth/refresh',
117-
// ]
118-
// ]
119-
// ]
120-
]
103+
// [
104+
// 'type' => 'http',
105+
// 'description' => 'description',
106+
// 'scheme' => 'Bearer',
107+
// 'bearerFormat' => 'JWT'
108+
// ],
109+
// [
110+
// 'type' => 'oauth2',
111+
// 'flows' => [
112+
// 'authorizationCode' => [
113+
// 'scopes' => ['write:pets'],
114+
// 'tokenUrl' => 'https://example.com/api/oauth/token',
115+
// 'authorizationUrl' => 'https://example.com/api/oauth/dialog',
116+
// 'refreshUrl' => 'https://example.com/api/oauth/refresh',
117+
// ]
118+
// ]
119+
// ]
120+
],
121121
],
122122
];

src/Actions/Action.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@
88
use Illuminate\Foundation\Bus\Dispatchable;
99
use Illuminate\Queue\InteractsWithQueue;
1010
use Illuminate\Queue\SerializesModels;
11-
use Illuminate\Support\Collection;
1211
use Illuminate\Support\Str;
1312
use Lomkit\Rest\Concerns\Fieldable;
1413
use Lomkit\Rest\Concerns\Makeable;
1514
use Lomkit\Rest\Concerns\Metable;
1615
use Lomkit\Rest\Concerns\Resourcable;
1716
use Lomkit\Rest\Http\Requests\OperateRequest;
1817
use Lomkit\Rest\Http\Requests\RestRequest;
19-
use Lomkit\Rest\Http\Resource;
2018

2119
class Action implements \JsonSerializable
2220
{
23-
use Makeable, Metable, Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Fieldable, Resourcable;
21+
use Makeable;
22+
use Metable;
23+
use Batchable;
24+
use Dispatchable;
25+
use InteractsWithQueue;
26+
use Queueable;
27+
use SerializesModels;
28+
use Fieldable;
29+
use Resourcable;
2430

2531
/**
2632
* The name of the connection the job should be sent to.
@@ -80,18 +86,19 @@ public function jsonSerialize(): array
8086
$request = app()->make(RestRequest::class);
8187

8288
return [
83-
'name' => $this->name(),
89+
'name' => $this->name(),
8490
'uriKey' => $this->uriKey(),
8591
'fields' => $this->fields($request),
86-
'meta' => $this->meta()
92+
'meta' => $this->meta(),
8793
];
8894
}
8995

9096
/**
9197
* Perform the action on the given models.
9298
*
93-
* @param array $fields
94-
* @param \Illuminate\Support\Collection $models
99+
* @param array $fields
100+
* @param \Illuminate\Support\Collection $models
101+
*
95102
* @return mixed
96103
*/
97104
public function handle(array $fields, \Illuminate\Support\Collection $models)
@@ -102,8 +109,9 @@ public function handle(array $fields, \Illuminate\Support\Collection $models)
102109
/**
103110
* Register callbacks on the pending batch.
104111
*
105-
* @param array $fields
106-
* @param \Illuminate\Bus\PendingBatch $batch
112+
* @param array $fields
113+
* @param \Illuminate\Bus\PendingBatch $batch
114+
*
107115
* @return void
108116
*/
109117
public function withBatch(array $fields, PendingBatch $batch)
@@ -114,10 +122,11 @@ public function withBatch(array $fields, PendingBatch $batch)
114122
/**
115123
* Execute the action for the given request.
116124
*
117-
* @param OperateRequest $request
118-
* @return int
125+
* @param OperateRequest $request
119126
*
120127
* @throws \Throwable
128+
*
129+
* @return int
121130
*/
122131
public function handleRequest(OperateRequest $request)
123132
{
@@ -129,4 +138,4 @@ public function handleRequest(OperateRequest $request)
129138

130139
return $count;
131140
}
132-
}
141+
}

src/Actions/Actionable.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,31 @@
77
trait Actionable
88
{
99
/**
10-
* The actions that should be linked
10+
* The actions that should be linked.
11+
*
1112
* @param RestRequest $request
13+
*
1214
* @return array
1315
*/
14-
public function actions(RestRequest $request): array {
16+
public function actions(RestRequest $request): array
17+
{
1518
return [];
1619
}
1720

18-
public function actionExists(RestRequest $request, string $actionKey): bool {
21+
public function actionExists(RestRequest $request, string $actionKey): bool
22+
{
1923
return collect($this->actions($request))
2024
->contains(function (Action $action) use ($actionKey) {
2125
return $action->uriKey() === $actionKey;
2226
});
2327
}
2428

25-
public function action(RestRequest $request, string $actionKey): Action {
29+
public function action(RestRequest $request, string $actionKey): Action
30+
{
2631
return collect($this->actions($request))
2732
->sole(function (Action $action) use ($actionKey) {
2833
return $action->uriKey() === $actionKey;
2934
})
3035
->resource($this);
3136
}
32-
}
37+
}

src/Actions/CallRestApiAction.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
class CallRestApiAction
1313
{
14-
use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
14+
use Batchable;
15+
use Dispatchable;
16+
use InteractsWithQueue;
17+
use Queueable;
18+
use SerializesModels;
1519

1620
/**
1721
* Models collection.
@@ -37,9 +41,10 @@ class CallRestApiAction
3741
/**
3842
* Create a new job instance.
3943
*
40-
* @param \Lomkit\Rest\Actions\Action $action
41-
* @param array $fields
42-
* @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection $models
44+
* @param \Lomkit\Rest\Actions\Action $action
45+
* @param array $fields
46+
* @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection $models
47+
*
4348
* @return void
4449
*/
4550
public function __construct(Action $action, array $fields, Collection $models)
@@ -68,4 +73,4 @@ public function displayName()
6873
{
6974
return get_class($this->action);
7075
}
71-
}
76+
}

0 commit comments

Comments
 (0)