Skip to content

Instantly share code, notes, and snippets.

@ftkro
Created December 22, 2014 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftkro/f44eec8c2138a1f544e5 to your computer and use it in GitHub Desktop.
Save ftkro/f44eec8c2138a1f544e5 to your computer and use it in GitHub Desktop.
LibFizzBuzz
<?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
}
}
}
@ftkro
Copy link
Author

ftkro commented Dec 22, 2014

単なるゴミですね、こんなスクリプト

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment