-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
refactor: use ternary operators in Helpers #8529
Conversation
I agree with @kenjis. I'm against micro-optimization that sacrifices the readability and maintainability of code. |
c521ed7
to
11db748
Compare
system/Helpers/html_helper.php
Outdated
. _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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change.
system/Helpers/html_helper.php
Outdated
} else { | ||
$img .= ' src="' . slash_item('baseURL') . $src['src'] . '"'; | ||
} | ||
$img .= $indexPage === true ? ' src="' . site_url($src['src']) . '"' : ' src="' . slash_item('baseURL') . $src['src'] . '"'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change.
system/Helpers/html_helper.php
Outdated
} else { | ||
$script .= 'src="' . slash_item('baseURL') . $v . '" '; | ||
} | ||
$script .= $indexPage === true ? 'src="' . site_url($v) . '" ' : 'src="' . slash_item('baseURL') . $v . '" '; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change.
system/Helpers/html_helper.php
Outdated
} else { | ||
$video .= ' src="' . slash_item('baseURL') . $src . '"'; | ||
} | ||
$video .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change.
system/Helpers/html_helper.php
Outdated
} else { | ||
$audio .= ' src="' . slash_item('baseURL') . $src . '"'; | ||
} | ||
$audio .= _has_protocol($src) ? ' src="' . $src . '"' : ($indexPage === true ? ' src="' . site_url($src) . '"' : ' src="' . slash_item('baseURL') . $src . '"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change.
system/Helpers/text_helper.php
Outdated
} else { | ||
$output .= $line . "\n"; | ||
} | ||
$output .= $temp !== '' ? $temp . "\n" . $line . "\n" : $line . "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change.
system/Helpers/text_helper.php
Outdated
} 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))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Helper
@ddevsr Thank you! |
Description
Just refactor to one liner.
Checklist: