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

refactor: use ternary operators in Helpers #8529

Merged
merged 5 commits into from
Feb 12, 2024

Conversation

ddevsr
Copy link
Collaborator

@ddevsr ddevsr commented Feb 9, 2024

Description
Just refactor to one liner.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@ddevsr ddevsr added the refactor Pull requests that refactor code label Feb 9, 2024
@michalsn
Copy link
Member

michalsn commented Feb 9, 2024

I agree with @kenjis. I'm against micro-optimization that sacrifices the readability and maintainability of code.

@ddevsr ddevsr force-pushed the refactor-possible-oneliner branch from c521ed7 to 11db748 Compare February 10, 2024 02:00
. _list($type, $val, '', $depth + 4)
. str_repeat(' ', $depth + 2);
}
$out .= ! is_array($val) ? $val : $key . "\n" . _list($type, $val, '', $depth + 4) . str_repeat(' ', $depth + 2);
Copy link
Member

Choose a reason for hiding this comment

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

Remove this change.

} else {
$img .= ' src="' . slash_item('baseURL') . $src['src'] . '"';
}
$img .= $indexPage === true ? ' src="' . site_url($src['src']) . '"' : ' src="' . slash_item('baseURL') . $src['src'] . '"';
Copy link
Member

Choose a reason for hiding this comment

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

Remove this change.

} else {
$script .= 'src="' . slash_item('baseURL') . $v . '" ';
}
$script .= $indexPage === true ? 'src="' . site_url($v) . '" ' : 'src="' . slash_item('baseURL') . $v . '" ';
Copy link
Member

Choose a reason for hiding this comment

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

Remove this change.

} else {
$video .= ' src="' . slash_item('baseURL') . $src . '"';
}
$video .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"');
Copy link
Member

Choose a reason for hiding this comment

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

Remove this change.

} else {
$audio .= ' src="' . slash_item('baseURL') . $src . '"';
}
$audio .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"');
Copy link
Member

Choose a reason for hiding this comment

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

Remove this change.

} else {
$output .= $line . "\n";
}
$output .= $temp !== '' ? $temp . "\n" . $line . "\n" : $line . "\n";
Copy link
Member

Choose a reason for hiding this comment

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

Remove this change.

} else {
$end = mb_substr($str, -($maxLength - mb_strlen($beg)));
}
$end = $position === 1 ? mb_substr($str, 0, -($maxLength - mb_strlen($beg))) : mb_substr($str, -($maxLength - mb_strlen($beg)));
Copy link
Member

Choose a reason for hiding this comment

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

Remove this change.

Copy link
Member

@kenjis kenjis left a comment

Choose a reason for hiding this comment

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

Thank you!

@kenjis kenjis changed the title refactor: possible one liner in Helper refactor: use ternary operators in Helpers Feb 10, 2024
@kenjis kenjis merged commit 4c9bf0e into codeigniter4:develop Feb 12, 2024
62 checks passed
@kenjis
Copy link
Member

kenjis commented Feb 12, 2024

@ddevsr Thank you!

@ddevsr ddevsr deleted the refactor-possible-oneliner branch February 12, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants