Skip to content

Commit 78487d4

Browse files
authored
Merge pull request #20 from mtrajano/analysis-KZZ4aR
Apply fixes from StyleCI
2 parents b571fa1 + b532ba1 commit 78487d4

19 files changed

+79
-81
lines changed

config/laravel-swagger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@
6262
*/
6363

6464
'parseDocBlock' => true,
65-
];
65+
];

src/FormatterManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ public function format()
4040
{
4141
return $this->formatter->format();
4242
}
43-
}
43+
}

src/Formatters/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public function __construct($docs)
1212
}
1313

1414
abstract public function format();
15-
}
15+
}

src/Formatters/JsonFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public function format()
1414

1515
return json_encode($this->docs, JSON_PRETTY_PRINT);
1616
}
17-
}
17+
}

src/Formatters/YamlFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public function format()
1414

1515
return yaml_emit($this->docs);
1616
}
17-
}
17+
}

src/Generator.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Mtrajano\LaravelSwagger;
44

5-
use ReflectionMethod;
6-
use Illuminate\Support\Str;
7-
use Illuminate\Routing\Route;
85
use Illuminate\Foundation\Http\FormRequest;
6+
use Illuminate\Routing\Route;
7+
use Illuminate\Support\Str;
98
use phpDocumentor\Reflection\DocBlockFactory;
9+
use ReflectionMethod;
1010

1111
class Generator
1212
{
@@ -53,7 +53,9 @@ public function generate()
5353
foreach ($methods as $method) {
5454
$this->method = strtolower($method);
5555

56-
if (in_array($this->method, $this->config['ignoredMethods'])) continue;
56+
if (in_array($this->method, $this->config['ignoredMethods'])) {
57+
continue;
58+
}
5759

5860
$this->generatePath();
5961
}
@@ -111,18 +113,18 @@ protected function getRouteUri(Route $route)
111113
protected function generatePath()
112114
{
113115
$actionInstance = is_string($this->action) ? $this->getActionClassInstance($this->action) : null;
114-
$docBlock = $actionInstance ? ($actionInstance->getDocComment() ?: "") : "";
116+
$docBlock = $actionInstance ? ($actionInstance->getDocComment() ?: '') : '';
115117

116-
list($isDeprecated, $summary, $description) = $this->parseActionDocBlock($docBlock);
118+
[$isDeprecated, $summary, $description] = $this->parseActionDocBlock($docBlock);
117119

118120
$this->docs['paths'][$this->uri][$this->method] = [
119121
'summary' => $summary,
120122
'description' => $description,
121123
'deprecated' => $isDeprecated,
122124
'responses' => [
123125
'200' => [
124-
'description' => 'OK'
125-
]
126+
'description' => 'OK',
127+
],
126128
],
127129
];
128130

@@ -148,7 +150,9 @@ protected function addActionParameters()
148150

149151
protected function getFormRules()
150152
{
151-
if (!is_string($this->action)) return false;
153+
if (!is_string($this->action)) {
154+
return false;
155+
}
152156

153157
$parameters = $this->getActionClassInstance($this->action)->getParameters();
154158

@@ -175,15 +179,15 @@ protected function getParameterGenerator($rules)
175179

176180
private function getActionClassInstance(string $action)
177181
{
178-
list($class, $method) = Str::parseCallback($action);
182+
[$class, $method] = Str::parseCallback($action);
179183

180184
return new ReflectionMethod($class, $method);
181185
}
182186

183187
private function parseActionDocBlock(string $docBlock)
184188
{
185189
if (empty($docBlock) || !$this->config['parseDocBlock']) {
186-
return [false, "", ""];
190+
return [false, '', ''];
187191
}
188192

189193
try {
@@ -195,8 +199,8 @@ private function parseActionDocBlock(string $docBlock)
195199
$description = (string) $parsedComment->getDescription();
196200

197201
return [$isDeprecated, $summary, $description];
198-
} catch(\Exception $e) {
199-
return [false, "", ""];
202+
} catch (\Exception $e) {
203+
return [false, '', ''];
200204
}
201205
}
202-
}
206+
}

src/LaravelSwaggerException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
class LaravelSwaggerException extends \Exception
66
{
7-
}
7+
}

src/Parameters/BodyParameterGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function addToProperties(&$properties, $nameTokens, $rules)
8181

8282
if ($type === 'array') {
8383
$this->addToProperties($properties[$name]['items'], $nameTokens, $rules);
84-
} else if ($type === 'object') {
84+
} elseif ($type === 'object') {
8585
$this->addToProperties($properties[$name]['properties'], $nameTokens, $rules);
8686
}
8787
}
@@ -98,7 +98,7 @@ protected function getNestedParamType($nameTokens)
9898
protected function getNewPropObj($type, $rules)
9999
{
100100
$propObj = [
101-
'type' => $type
101+
'type' => $type,
102102
];
103103

104104
if ($enums = $this->getEnumValues($rules)) {
@@ -107,10 +107,10 @@ protected function getNewPropObj($type, $rules)
107107

108108
if ($type === 'array') {
109109
$propObj['items'] = [];
110-
} else if ($type === 'object') {
110+
} elseif ($type === 'object') {
111111
$propObj['properties'] = [];
112112
}
113113

114114
return $propObj;
115115
}
116-
}
116+
}

src/Parameters/Concerns/GeneratesFromRules.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ protected function getParamType(array $paramRules)
1919
{
2020
if (in_array('integer', $paramRules)) {
2121
return 'integer';
22-
} else if (in_array('numeric', $paramRules)) {
22+
} elseif (in_array('numeric', $paramRules)) {
2323
return 'number';
24-
} else if (in_array('boolean', $paramRules)) {
24+
} elseif (in_array('boolean', $paramRules)) {
2525
return 'boolean';
26-
} else if (in_array('array', $paramRules)) {
26+
} elseif (in_array('array', $paramRules)) {
2727
return 'array';
2828
} else {
2929
//date, ip, email, etc..
@@ -54,15 +54,15 @@ protected function getEnumValues(array $paramRules)
5454
return [];
5555
}
5656

57-
list($param, $vals) = explode(':', $in);
57+
[$param, $vals] = explode(':', $in);
5858

5959
return explode(',', $vals);
6060
}
6161

6262
private function getInParameter(array $paramRules)
6363
{
6464
foreach ($paramRules as $rule) {
65-
if ((is_string($rule) || method_exists($rule , '__toString')) && Str::startsWith($rule, 'in:')) {
65+
if ((is_string($rule) || method_exists($rule, '__toString')) && Str::startsWith($rule, 'in:')) {
6666
return $rule;
6767
}
6868
}

src/Parameters/ParameterGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ interface ParameterGenerator
77
public function getParameters();
88

99
public function getParamLocation();
10-
}
10+
}

0 commit comments

Comments
 (0)