Sha256: 3dd2b72812d28bf9db392e328c678b222a366ee081c3aa118208524b15359c40
Contents?: true
Size: 1.3 KB
Versions: 396
Compression:
Stored size: 1.3 KB
Contents
<?php class BeerSong { public function verse($number) { $decrement = $number - 1; switch ($number) { case 0: return "No more bottles of beer on the wall, no more bottles of beer.\n" . "Go to the store and buy some more, 99 bottles of beer on the wall."; case 1: return "1 bottle of beer on the wall, 1 bottle of beer.\n" . "Take it down and pass it around, no more bottles of beer on the wall.\n"; case 2: return "2 bottles of beer on the wall, 2 bottles of beer.\n" . "Take one down and pass it around, 1 bottle of beer on the wall.\n"; default: return "{$number} bottles of beer on the wall, {$number} bottles of beer.\n" . "Take one down and pass it around, {$decrement} bottles of beer on the wall.\n"; } } public function verses($start, $finish) { $output = ''; foreach (range($start, $finish) as $number) { $output .= $this->verse($number); if ($number > $finish) { $output .= "\n"; } } return $output; } public function lyrics() { return $this->verses(99, 0); } }
Version data entries
396 entries across 396 versions & 1 rubygems