Created
December 22, 2014 12:15
-
-
Save ftkro/f44eec8c2138a1f544e5 to your computer and use it in GitHub Desktop.
LibFizzBuzz
This file contains hidden or 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 | |
/** | |
* FizzBuzz Lib is a Garbage(Gomi,53) | |
* | |
* @package LibFizzBuzz | |
* @author Fukuda Takuro | |
* @since PHP 5.5 | |
* @version 1.0 | |
*/ | |
class FizzBuzz { | |
protected $num; | |
protected $max; | |
protected $min; | |
protected $val; | |
public function Rand($max=NULL,$min=NULL) { | |
if(is_null($max) and is_null($min)) { | |
$num = mt_rand(1, 512); | |
} elseif(is_null($min)) { | |
if(is_int($min) and is_int($max)) { | |
$num = mt_rand(1,$max); | |
} else { | |
trigger_error('Need Int Value',E_USER_ERROR); | |
$num = 0; | |
} | |
} elseif(is_null($max)) { | |
if(is_int($min) and is_int($max) and $min <= 512) { | |
$num = mt_rand($min,512); | |
} else { | |
trigger_error('No Larger Min Value',E_USER_ERROR); | |
$num = 0; | |
} | |
} else { | |
if(is_int($min) and is_int($max) and $min <= $max) { | |
$num = mt_rand($min,$max); | |
} else { | |
trigger_error('No Larger Min Value',E_USER_ERROR); | |
$num = 0; | |
} | |
} | |
return $num; | |
} | |
public function Validation($val) { | |
if (isset($val) and is_int($val)) { | |
if (is_int($val / 15)) { | |
return 3; //FizzBuzz | |
} elseif (is_int($val / 5)) { | |
return 2; //Buzz | |
} elseif (is_int($val / 3)) { | |
return 1; //Fizz | |
} else { | |
return 0; //No All | |
} | |
} else { | |
trigger_error('Exception',E_USER_ERROR); | |
return false; //Exception | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
単なるゴミですね、こんなスクリプト