Last active
February 14, 2017 09:21
-
-
Save weburnit/0b6e80098c28b7bb963d069cd5ef0655 to your computer and use it in GitHub Desktop.
Wizeline Test in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Wizeline | |
{ | |
private $range; | |
public function __construct(int $range) | |
{ | |
$this->range = $range; | |
} | |
public function printNumbers(int $numbers = null) | |
{ | |
$numbers = $numbers ?? $this->range; | |
foreach(range(1, $numers) as $value){ | |
$this->printNumber($value); | |
} | |
} | |
private function printNumber(int $number) | |
{ | |
if(0 === $number%15){ | |
echo 'WizeLine'. PHP_EOL; | |
return; | |
} | |
if(0 === $number%5){ | |
echo 'Line'. PHP_EOL; | |
return; | |
} | |
if(0 === $number%3){ | |
echo 'Wize'. PHP_EOL; | |
return; | |
} | |
echo $number.PHP_EOL; | |
} | |
} | |
$tellme = new Wizeline(100); | |
$tellme->printNumbers(); | |
$tellme->printNumbers(200); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment