Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed May 9, 2020
1 parent 9da8c80 commit 93b2014
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions resources/views/partials/example-requests/php.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'{{ rtrim($baseUrl, '/') . '/' . ltrim($route['boundUri'], '/') }}',
[
@if(!empty($route['headers']))
'headers' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpArray($route['headers'], 8) !!},
'headers' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpValue($route['headers'], 8) !!},
@endif
@if(!empty($route['cleanQueryParameters']))
'query' => {!! \Knuckles\Scribe\Tools\WritingUtils::printQueryParamsAsKeyValue($route['cleanQueryParameters'], "'", "=>", 12, "[]", 8) !!},
Expand All @@ -29,7 +29,7 @@
@endforeach
],
@elseif(!empty($route['cleanBodyParameters']))
'json' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpArray($route['cleanBodyParameters'], 8) !!},
'json' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpValue($route['cleanBodyParameters'], 8) !!},
@endif
]
);
Expand Down
4 changes: 2 additions & 2 deletions src/Extracting/ValidationRuleDescriptionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public static function getDescription(string $rule, array $arguments = [], $type
return $instance->makeDescription($type);
}

protected function makeDescription($type = 'string'): string
protected function makeDescription($baseType = 'string'): string
{
$description = trans("validation.{$this->rule}");
// For rules that can apply to multiple types (eg 'max' rule), Laravel returns an array of possible messages
// 'numeric' => 'The :attribute must not be greater than :max'
// 'file' => 'The :attribute must have a size less than :max kilobytes'
if (is_array($description)) {
$description = $description[$type];
$description = $description[$baseType];
}

// Convert messages from failure type ("The value is not a valid date.") to info ("The value must be a valid date.")
Expand Down
6 changes: 4 additions & 2 deletions src/Tools/WritingUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ class WritingUtils
];

/**
* @param array $value
* Print a value as valid PHP, handling arrays and proper indentation.
*
* @param $value
* @param int $indentationLevel
*
* @return string
* @throws \Symfony\Component\VarExporter\Exception\ExceptionInterface
*
*/
public static function printPhpArray($value, int $indentationLevel = 0): string
public static function printPhpValue($value, int $indentationLevel = 0): string
{
$output = VarExporter::export($value);
// Padding with x spaces so they align
Expand Down

0 comments on commit 93b2014

Please sign in to comment.