Skip to content

Commit 1896b8d

Browse files
z-songStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent cd0b819 commit 1896b8d

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

src/ApiLogger.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
use Illuminate\Support\Facades\File;
66

77
/**
8-
* Class ApiLogger
9-
* @package Encore\Admin\ApiTester
8+
* Class ApiLogger.
109
*
1110
* @deprecated
1211
*/
@@ -33,7 +32,7 @@ public static function load()
3332

3433
$data = File::get($logPath);
3534

36-
$json = '['.trim($data, ','). ']';
35+
$json = '['.trim($data, ',').']';
3736

3837
$history = array_reverse(json_decode($json, true));
3938

@@ -54,11 +53,11 @@ public static function formatParameters($parameters = [])
5453

5554
foreach ($parameters as $name => $value) {
5655
$retval[] = [
57-
'name' => $name,
56+
'name' => $name,
5857
'defaultValue' => $value,
5958
];
6059
}
6160

6261
return json_encode($retval);
6362
}
64-
}
63+
}

src/ApiTester.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ApiTester extends Extension
3636

3737
/**
3838
* ApiTester constructor.
39+
*
3940
* @param \Illuminate\Foundation\Application|null $app
4041
*/
4142
public function __construct(\Illuminate\Foundation\Application $app = null)
@@ -48,6 +49,7 @@ public function __construct(\Illuminate\Foundation\Application $app = null)
4849
* @param string $uri
4950
* @param array $parameters
5051
* @param string $userId
52+
*
5153
* @return \Symfony\Component\HttpFoundation\Response
5254
*/
5355
public function call($method, $uri, $parameters = [], $user = null)
@@ -109,6 +111,7 @@ protected function loginUsing($userId)
109111

110112
/**
111113
* @param Response $response
114+
*
112115
* @return array
113116
*/
114117
public function parseResponse(Response $response)
@@ -142,6 +145,7 @@ public function parseResponse(Response $response)
142145

143146
/**
144147
* @param Response $response
148+
*
145149
* @return string
146150
*/
147151
protected function getStatusText(Response $response)
@@ -156,7 +160,8 @@ protected function getStatusText(Response $response)
156160
/**
157161
* Filter the given array of files, removing any empty values.
158162
*
159-
* @param array $files
163+
* @param array $files
164+
*
160165
* @return mixed
161166
*/
162167
protected function filterFiles($files)
@@ -167,7 +172,7 @@ protected function filterFiles($files)
167172
}
168173

169174
if (is_array($file)) {
170-
if (! isset($file['name'])) {
175+
if (!isset($file['name'])) {
171176
$files[$key] = $this->filterFiles($files[$key]);
172177
} elseif (isset($files[$key]['error']) && $files[$key]['error'] !== 0) {
173178
unset($files[$key]);
@@ -185,7 +190,8 @@ protected function filterFiles($files)
185190
/**
186191
* Turn the given URI into a fully qualified URL.
187192
*
188-
* @param string $uri
193+
* @param string $uri
194+
*
189195
* @return string
190196
*/
191197
protected function prepareUrlForRequest($uri)
@@ -194,7 +200,7 @@ protected function prepareUrlForRequest($uri)
194200
$uri = substr($uri, 1);
195201
}
196202

197-
if (! Str::startsWith($uri, 'http')) {
203+
if (!Str::startsWith($uri, 'http')) {
198204
$uri = config('app.url').'/'.$uri;
199205
}
200206

@@ -213,9 +219,7 @@ public function getRoutes()
213219
$prefix = static::config('prefix');
214220

215221
$routes = collect($routes)->filter(function ($route) use ($prefix) {
216-
217222
return Str::startsWith($route->uri, static::config('prefix'));
218-
219223
})->map(function ($route) {
220224
return $this->getRouteInformation($route);
221225
})->all();
@@ -239,6 +243,7 @@ public function getRoutes()
239243
* Get parameters info of route.
240244
*
241245
* @param $action
246+
*
242247
* @return array
243248
*/
244249
protected function getRouteParameters($action)
@@ -247,12 +252,12 @@ protected function getRouteParameters($action)
247252
return [];
248253
}
249254

250-
if (is_string($action) && ! Str::contains($action, '@')) {
255+
if (is_string($action) && !Str::contains($action, '@')) {
251256
list($class, $method) = static::makeInvokable($action);
252257
} else {
253258
list($class, $method) = explode('@', $action);
254259
}
255-
260+
256261
$classReflector = new \ReflectionClass($class);
257262

258263
$comment = $classReflector->getMethod($method)->getDocComment();
@@ -263,7 +268,6 @@ protected function getRouteParameters($action)
263268
foreach (array_get($matches, 1, []) as $item) {
264269
preg_match_all('/(\w+)=[\'"]?([^\r\n"]+)[\'"]?,?\n/s', $item, $match);
265270
if (count($match) == 3) {
266-
267271
$match[2] = array_map(function ($val) {
268272
return trim($val, ',');
269273
}, $match[2]);
@@ -280,11 +284,12 @@ protected function getRouteParameters($action)
280284

281285
/**
282286
* @param $action
287+
*
283288
* @return array
284289
*/
285290
protected static function makeInvokable($action)
286291
{
287-
if (! method_exists($action, '__invoke')) {
292+
if (!method_exists($action, '__invoke')) {
288293
throw new \UnexpectedValueException("Invalid route action: [{$action}].");
289294
}
290295

@@ -294,7 +299,8 @@ protected static function makeInvokable($action)
294299
/**
295300
* Get the route information for a given route.
296301
*
297-
* @param \Illuminate\Routing\Route $route
302+
* @param \Illuminate\Routing\Route $route
303+
*
298304
* @return array
299305
*/
300306
protected function getRouteInformation(Route $route)
@@ -312,8 +318,9 @@ protected function getRouteInformation(Route $route)
312318
/**
313319
* Sort the routes by a given element.
314320
*
315-
* @param string $sort
316-
* @param array $routes
321+
* @param string $sort
322+
* @param array $routes
323+
*
317324
* @return array
318325
*/
319326
protected function sortRoutes($sort, $routes)
@@ -326,7 +333,8 @@ protected function sortRoutes($sort, $routes)
326333
/**
327334
* Get before filters.
328335
*
329-
* @param \Illuminate\Routing\Route $route
336+
* @param \Illuminate\Routing\Route $route
337+
*
330338
* @return string
331339
*/
332340
protected function getRouteMiddleware($route)
@@ -335,4 +343,4 @@ protected function getRouteMiddleware($route)
335343
return $middleware instanceof \Closure ? 'Closure' : $middleware;
336344
});
337345
}
338-
}
346+
}

src/ApiTesterController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ class ApiTesterController extends Controller
1212
public function index()
1313
{
1414
return Admin::content(function (Content $content) {
15-
1615
$content->header('Api tester');
1716

1817
$tester = new ApiTester();
1918

20-
$content->body(view('api-tester::index', [
19+
$content->body(view('api-tester::index', [
2120
'routes' => $tester->getRoutes(),
2221
// 'logs' => ApiLogger::load(),
2322
]));
@@ -27,14 +26,15 @@ public function index()
2726
public function handle(Request $request)
2827
{
2928
$method = $request->get('method');
30-
$uri = $request->get('uri');
31-
$user = $request->get('user');
29+
$uri = $request->get('uri');
30+
$user = $request->get('user');
3231
$all = $request->all();
3332

34-
$keys = array_get($all, 'key', []);
35-
$vals = array_get($all, 'val', []);
33+
$keys = array_get($all, 'key', []);
34+
$vals = array_get($all, 'val', []);
3635

37-
ksort($keys);ksort($vals);
36+
ksort($keys);
37+
ksort($vals);
3838

3939
$parameters = [];
4040

@@ -53,7 +53,7 @@ public function handle(Request $request)
5353
return [
5454
'status' => true,
5555
'message' => 'success',
56-
'data' => $tester->parseResponse($response)
56+
'data' => $tester->parseResponse($response),
5757
];
5858
}
59-
}
59+
}

src/ApiTesterServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ public function boot()
1919

2020
ApiTester::boot();
2121
}
22-
}
22+
}

src/BootExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ public static function importAssets()
5050
Admin::js('/vendor/api-tester/prism.js');
5151
Admin::css('/vendor/api-tester/prism.css');
5252
}
53-
}
53+
}

0 commit comments

Comments
 (0)