Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Mar 7, 2020
1 parent b0ddb97 commit 385fbc7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
10 changes: 1 addition & 9 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
preset: laravel
preset: psr12

enabled:
- phpdoc_order
- phpdoc_separation
- unalign_double_arrow

disabled:
- short_list_syntax
- simplified_null_return
20 changes: 9 additions & 11 deletions src/Tools/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Mpociot\ApiDoc\Tools;

use Illuminate\Routing\Route;
use Illuminate\Support\Arr;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Symfony\Component\Console\Output\ConsoleOutput;
Expand Down Expand Up @@ -90,7 +89,7 @@ public static function dumpException(\Exception $e)

public static function deleteDirectoryAndContents($dir)
{
$dir = ltrim($dir, "/");
$dir = ltrim($dir, '/');
$adapter = new Local(realpath(__DIR__ . '/../../'));
$fs = new Filesystem($adapter);
$fs->deleteDir($dir);
Expand All @@ -104,7 +103,7 @@ public static function deleteDirectoryAndContents($dir)
* @throws \Symfony\Component\VarExporter\Exception\ExceptionInterface
*
*/
public static function printPhpValue($value, $indentationLevel = 0)
public static function printPhpValue($value, int $indentationLevel = 0): string
{
$output = VarExporter::export($value);
// Padding with x spaces so they align
Expand All @@ -120,7 +119,7 @@ public static function printPhpValue($value, $indentationLevel = 0)

public static function printQueryParamsAsString(array $cleanQueryParams): string
{
$qs = "";
$qs = '';
foreach ($cleanQueryParams as $parameter => $value) {
$paramName = urlencode($parameter);

Expand All @@ -129,14 +128,13 @@ public static function printQueryParamsAsString(array $cleanQueryParams): string
} else {
if (array_keys($value)[0] === 0) {
// List query param (eg filter[]=haha should become "filter[]": "haha")
$qs .= "$paramName" . "[]=" . urlencode($value[0]) . "&";
$qs .= "$paramName" . '[]=' . urlencode($value[0]) . '&';
} else {
// Hash query param (eg filter[name]=john should become "filter[name]": "john")
foreach ($value as $item => $itemValue) {
$qs .= "$paramName" . "[" . urlencode($item) . "]=" . urlencode($itemValue) . "&";
$qs .= "$paramName" . '[' . urlencode($item) . ']=' . urlencode($itemValue) . '&';
}
}

}
}

Expand All @@ -156,23 +154,23 @@ public static function printQueryParamsAsKeyValue(
foreach ($cleanQueryParams as $parameter => $value) {
if (!is_array($value)) {
$output .= str_repeat(" ", $spacesIndentation);
$output .= "$quote$parameter$quote$delimiter $quote$value$quote,\n";
$output .= "$quote$parameter$quote$delimiter $quote$value$quote,\n";
} else {
if (array_keys($value)[0] === 0) {
// List query param (eg filter[]=haha should become "filter[]": "haha")
$output .= str_repeat(" ", $spacesIndentation);
$output .= "$quote$parameter"."[]$quote$delimiter $quote$value[0]$quote,\n";
$output .= "$quote$parameter" . "[]$quote$delimiter $quote$value[0]$quote,\n";
} else {
// Hash query param (eg filter[name]=john should become "filter[name]": "john")
foreach ($value as $item => $itemValue) {
$output .= str_repeat(" ", $spacesIndentation);
$output .= "$quote$parameter"."[$item]$quote$delimiter $quote$itemValue$quote,\n";
$output .= "$quote$parameter" . "[$item]$quote$delimiter $quote$itemValue$quote,\n";
}
}

}
}

return $output.str_repeat(" ", $closingBraceIndentation)."{$braces[1]}";
return $output . str_repeat(" ", $closingBraceIndentation) . "{$braces[1]}";
}
}

0 comments on commit 385fbc7

Please sign in to comment.