Last active
December 21, 2015 18:39
-
-
Save alea12/6348800 to your computer and use it in GitHub Desktop.
降水量をもとに、雨の強さを気象庁風に表現する
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 | |
| /** | |
| * 降水量をもとに、雨の強さを気象庁風に表現する | |
| * 参考: 気象庁 | 雨と風の表 http://www.jma.go.jp/jma/kishou/know/yougo_hp/amehyo.html | |
| * | |
| * @example | |
| * <code> | |
| * echo getRainstatus(15); // => 'やや強い雨' | |
| * </code> | |
| * @access public | |
| * @param int $rainfall [mm/h] | |
| * @return string $rainstatus | |
| **/ | |
| public function getRainstatus($rainfall) { | |
| if (!is_numeric($rainfall) || $rainfall < 0) return false; | |
| if (0 < $rainfall && $rainfall < 10) { | |
| $rainstatus = '雨'; | |
| } elseif ($rainfall < 20) { | |
| $rainstatus = 'やや強い雨'; | |
| } elseif ($rainfall < 30) { | |
| $rainstatus = '強い雨'; | |
| } elseif ($rainfall < 50) { | |
| $rainstatus = '激しい雨'; | |
| } elseif ($rainfall < 80) { | |
| $rainstatus = '非常に激しい雨'; | |
| } elseif ($rainfall >= 80) { | |
| $rainstatus = '猛烈な雨'; | |
| } | |
| return $rainstatus; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment