Skip to content

Commit

Permalink
Fix: optimized the switch cases to ensure code reachability
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthaknagoshe2002 committed Dec 10, 2024
1 parent a3371b0 commit 386a8c0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/block-library/src/query-total/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ function render_block_core_query_total( $attributes, $content, $block ) {
// Prepare the display based on the `displayType` attribute.
$output = '';
switch ( $attributes['displayType'] ) {
case 'total-results':
default:
$output = sprintf(
'<p><strong>%d</strong> %s</p>',
$max_rows,
_n( 'result found', 'results found', $max_rows )
);
break;

case 'range-display':
if ( $start === $end ) {
$range_text = sprintf(
Expand All @@ -67,6 +58,15 @@ function render_block_core_query_total( $attributes, $content, $block ) {

$output = sprintf( '<p>%s</p>', $range_text );
break;

case 'total-results':
default:
$output = sprintf(
'<p><strong>%d</strong> %s</p>',
$max_rows,
_n( 'result found', 'results found', $max_rows )
);
break;
}

return sprintf(
Expand Down

0 comments on commit 386a8c0

Please sign in to comment.