-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.php
37 lines (32 loc) · 1.31 KB
/
status.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require_once "aqi.php";
function statusFor($aqi) {
return 'ดัชนีคุณภาพอากาศ (AQI): ' . $aqi . " " . emojiFor($aqi) . "\n" . messageFor($aqi);
}
function statusEnFor($aqi) {
switch (true) {
case $aqi <= LIMIT_GOOD: return "Good";
case $aqi <= LIMIT_MODERATE: return "Moderate";
case $aqi <= LIMIT_UNHEALTHY_SENSITIVE: return "Unhealthy for Sensitive Groups";
case $aqi <= LIMIT_UNHEALTHY: return "Unhealthy";
case $aqi <= LIMIT_VERY_UNHEALTY: return "Very Unhealthy";
default: return "Hazardous";
}
}
function statusThFor($aqi) {
switch (true) {
case $aqi <= LIMIT_GOOD: return "คุณภาพดี";
case $aqi <= LIMIT_MODERATE: return "คุณภาพปานกลาง";
case $aqi <= LIMIT_UNHEALTHY_SENSITIVE: return "มีผลกระทบต่อสุขภาพ";
case $aqi <= LIMIT_UNHEALTHY: return "มีผลกระทบต่อสุขภาพ";
case $aqi <= LIMIT_VERY_UNHEALTY: return "มีผลกระทบต่อสุขภาพมาก";
default: return "อันตราย";
}
}
function messageFor($aqi) {
$emoji = emojiFor($aqi);
$thaiMessage = statusThFor($aqi);
$engMessage = statusEnFor($aqi);
return $emoji . " " . $thaiMessage . "\n" . $emoji . " " . $engMessage;
}
?>