Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract parameter formatting from Version class and move to Parameter… #641

Merged
merged 1 commit into from
May 6, 2018

Conversation

jwage
Copy link
Member

@jwage jwage commented May 6, 2018

Fixes #640

@jwage jwage added this to the 2.0 milestone May 6, 2018
@jwage jwage self-assigned this May 6, 2018
@jwage jwage requested a review from Majkl578 May 6, 2018 20:48
*/
public function formatParameters(array $params, array $types) : string
{
if (empty($params)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid empty(), either use count(...) !== 0 or !== []

$out = [];
foreach ($params as $key => $value) {
$type = $types[$key] ?? 'string';
$outval = '[' . $this->formatParameter($value, $type) . ']';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$formattedValue

private function parameterToString($value) : string
{
if (is_array($value)) {
return implode(', ', array_map([$this, 'parameterToString'], $value));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use closure here instead of string name.

}

/**
* @param int[]|bool[]|string[]|array|int|string|bool $value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function is doing recursion 🤔

@jwage jwage force-pushed the extract-parameter-formatting branch from 17443b9 to 1f4925f Compare May 6, 2018 21:08
@jwage jwage merged commit bcbed01 into master May 6, 2018
@jwage jwage deleted the extract-parameter-formatting branch May 6, 2018 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants