Skip to content

Instantly share code, notes, and snippets.

@peakode
Last active February 9, 2016 11:06
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 peakode/a27ddf6e2282e7fff57e to your computer and use it in GitHub Desktop.
Save peakode/a27ddf6e2282e7fff57e to your computer and use it in GitHub Desktop.
Device.php sınıfı, iOS platform adı sistem çıktısını ilgili iOS cihaz bilgisine çevirmenizi sağlar. Her yıl Apple tarafından farklı iOS cihazlar tanıtıldığından bu bilgileri iOS uygulamasında gömülü olarak çevirmektense bu sınıf aracılığıyla çevirmek iş yükünü azaltıyor.
<?php
/**
*
*/
class Device
{
public function getModel($os, $platform) {
if ($os == "ios") {
if ($platform == "iPhone1,1") {
return "iPhone 1";
} elseif ($platform == "iPhone1,2") {
return "iPhone 3G";
} elseif ($platform == "iPhone2") {
return "iPhone 3GS";
} elseif ($platform == "iPhone3,1") {
return "iPhone 4";
} elseif ($platform == "iPhone3,2") {
return "iPhone 4";
} elseif ($platform == "iPhone3,3") {
return "iPhone 4";
} elseif ($platform == "iPhone4") {
return "iPhone 4S";
} elseif ($platform == "iPhone5,1") {
return "iPhone 5";
} elseif ($platform == "iPhone5,2") {
return "iPhone 5";
} elseif ($platform == "iPhone5,3") {
return "iPhone 5C";
} elseif ($platform == "iPhone5,4") {
return "iPhone 5C";
} elseif ($platform == "iPhone6,1") {
return "iPhone 5S";
} elseif ($platform == "iPhone6,2") {
return "iPhone 5S";
} elseif ($platform == "iPhone7,1") {
return "iPhone 6 Plus";
} elseif ($platform == "iPhone7,2") {
return "iPhone 6";
} elseif ($platform == "iPhone8,1") {
return "iPhone 6S";
} elseif ($platform == "iPhone8,2") {
return "iPhone 6S Plus";
} elseif ($platform == "iPod1") {
return "iPod touch 1";
} elseif ($platform == "iPod2,2") {
return "iPod touch 2";
} elseif ($platform == "iPod2") {
return "iPod touch 3";
} elseif ($platform == "iPod3") {
return "iPod touch 4";
} elseif ($platform == "iPod4") {
return "iPod touch 5";
} elseif ($platform == "iPod5") {
return "iPod touch 6";
} elseif ($platform == "iPad2,1" || $platform == "iPad2,2" || $platform == "iPad2,3" || $platform == "iPad2,4") {
return "iPad 2";
} elseif ($platform == "iPad3,1" || $platform == "iPad3,2" || $platform == "iPad3,3") {
return "iPad 3";
} elseif ($platform == "iPad3,4" || $platform == "iPad3,5" || $platform == "iPad3,6") {
return "iPad 4";
} elseif ($platform == "iPad4,1" || $platform == "iPad4,2" || $platform == "iPad4,3") {
return "iPad Air";
} elseif ($platform == "iPad5,3" || $platform == "iPad5,4") {
return "iPad Air 2";
} elseif ($platform == "iPad2,7" || $platform == "iPad2,6" || $platform == "iPad2,5" ) {
return "iPad Mini";
} elseif ($platform == "iPad4,6") {
return "iPad Mini 2";
} elseif ($platform == "iPad4,5") {
return "iPad Mini 2";
} elseif ($platform == "iPad4,4") {
return "iPad Mini 2";
} elseif ($platform == "iPad4,9") {
return "iPad Mini 3";
} elseif ($platform == "iPad4,8") {
return "iPad Mini 3";
} elseif ($platform == "iPad4,7") {
return "iPad Mini 3";
} elseif ($platform == "iPad5,2") {
return "iPad Mini 4";
} elseif ($platform == "iPad5,1") {
return "iPad Mini 4";
} elseif ($platform == "iPad6,8" || $platform == "iPad6,7") {
return "iPad Pro";
} elseif ($platform == "AppleTV5,3") {
return "Apple TV";
} elseif ($platform == "i386") {
return "Simulator";
} elseif ($platform == "x86_64") {
return "Simulator";
} else {
return "Unknown";
}
} else {
return "android device";
}
/*
if ($os == "ios") {
return "ios device";
} elseif ($os == "android") {
return "android device";
} else {
return "another operating system";
}
*/
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment