Created
December 5, 2009 22:18
-
-
Save mheadd/249884 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/* | |
* Class to compare user agent string with Voxeo Prophcy versions. | |
*/ | |
class sniffer { | |
private $smsUserAgentString = 'Voxeo-VXML/10'; | |
private $phoneUserAgentString = 'Voxeo-VXML/8'; | |
private $user_agent; | |
private $channelType; | |
public function __construct($user_agent) { | |
$this->user_agent = $user_agent; | |
} | |
public function getChannelType() { | |
if (strstr($this->user_agent, $this->phoneUserAgentString)) { | |
$this->channelType = 'phone'; | |
} | |
else if (strstr($this->user_agent, $this->smsUserAgentString)) { | |
$this->channelType = 'sms'; | |
} | |
else { | |
throw new badSnifferException("An invalid user agent type was detected."); | |
} | |
return $this->channelType; | |
} | |
} | |
/* | |
* Simple class definition to handle instances where the user agent is not known. | |
*/ | |
class badSnifferException extends Exception { } | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment