Skip to content

Commit

Permalink
Change if/else to switch logic
Browse files Browse the repository at this point in the history
  • Loading branch information
alexchantastic committed Jul 3, 2018
1 parent c0fd664 commit 419d4e7
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions script.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ function characters($count) {
return $words;
}

if ($type === 'characters') {
echo ucfirst(characters($length));
}
elseif ($type === 'words') {
echo ucfirst($lipsum->words($length));
}
elseif ($type === 'sentences') {
echo ucfirst($lipsum->sentences($length));
}
elseif ($type === 'paragraphs') {
echo ucfirst($lipsum->paragraphs($length));
switch ($type) {
case 'characters':
$output = characters($length);
break;
case 'words':
$output = $lipsum->words($length);
break;
case 'sentences':
$output = $lipsum->sentences($length);
break;
case 'paragraphs':
$output = $lipsum->paragraphs($length);
break;
}

echo ucfirst($output);

0 comments on commit 419d4e7

Please sign in to comment.