cvs: pear /Net_UserAgent_Mobile Mobile.php
[email protected] ("KUBO Atsuhiro") Sat, 10 May 2008 03:06:35 -0000
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvskuboa1210388795@cvsserver> |
kuboa Sat May 10 03:06:35 2008 UTC
Modified files:
/pear/Net_UserAgent_Mobile Mobile.php
Log:
- Some minor improvements and updates.
http://cvs.php.net/viewvc.cgi/pear/Net_UserAgent_Mobile/Mobile.php?r1=1.37&r2=1.38&diff_format=u
Index: pear/Net_UserAgent_Mobile/Mobile.php
diff -u pear/Net_UserAgent_Mobile/Mobile.php:1.37 pear/Net_UserAgent_Mobile/Mobile.php:1.38
--- pear/Net_UserAgent_Mobile/Mobile.php:1.37 Mon Feb 18 03:02:39 2008
+++ pear/Net_UserAgent_Mobile/Mobile.php Sat May 10 03:06:35 2008
@@ -15,7 +15,7 @@
* @author KUBO Atsuhiro <[email protected]>
* @copyright 2003-2008 KUBO Atsuhiro <[email protected]>
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Mobile.php,v 1.37 2008/02/18 03:02:39 kuboa Exp $
+ * @version CVS: $Id: Mobile.php,v 1.38 2008/05/10 03:06:35 kuboa Exp $
* @since File available since Release 0.1
*/
@@ -47,13 +47,10 @@
/**
* HTTP mobile user agent string parser
*
- * Net_UserAgent_Mobile parses HTTP_USER_AGENT strings of (mainly Japanese)
- * mobile HTTP user agents. It'll be useful in page dispatching by user
- * agents.
+ * Net_UserAgent_Mobile parses HTTP_USER_AGENT strings of (mainly Japanese) mobile
+ * HTTP user agents. It'll be useful in page dispatching by user agents.
* This package was ported from Perl's HTTP::MobileAgent.
* See {@link http://search.cpan.org/search?mode=module&query=HTTP-MobileAgent}
- * The author of the HTTP::MobileAgent module is Tatsuhiko Miyagawa
- * <[email protected]>
*
* SYNOPSIS:
* <code>
@@ -67,9 +64,9 @@
* // or if (strtolower(get_class($agent)) == 'http_mobileagent_docomo')
* // it's NTT DoCoMo i-mode
* // see what's available in Net_UserAgent_Mobile_DoCoMo
- * } elseif ($agent->isVodafone()) {
- * // it's Vodafone(J-PHONE)
- * // see what's available in Net_UserAgent_Mobile_Vodafone
+ * } elseif ($agent->isSoftBank()) {
+ * // it's SoftBank
+ * // see what's available in Net_UserAgent_Mobile_SoftBank
* } elseif ($agent->isEZweb()) {
* // it's KDDI/EZWeb
* // see what's available in Net_UserAgent_Mobile_EZweb
@@ -125,8 +122,9 @@
* If no argument is supplied, $_SERVER{'HTTP_*'} is used.
*
* @param string $userAgent User-Agent string
- * @return mixed a newly created Net_UserAgent_Mobile object, or a PEAR
- * error object on error
+ * @return Net_UserAgent_Mobile_Common|Net_UserAgent_Mobile_Error a newly created
+ * or an existing Net_UserAgent_Mobile_Common object, or a PEAR error object
+ * on error
*/
function &factory($userAgent = null)
{
@@ -181,12 +179,13 @@
// {{{ singleton()
/**
- * creates a new {@link Net_UserAgent_Mobile_Common} subclass instance or
- * returns a instance from existent ones
+ * creates a new {@link Net_UserAgent_Mobile_Common} subclass instance or returns
+ * a instance from existent ones
*
* @param string $userAgent User-Agent string
- * @return mixed a newly created or a existent Net_UserAgent_Mobile
- * object, or a PEAR error object on error
+ * @return Net_UserAgent_Mobile_Common|Net_UserAgent_Mobile_Error a newly created
+ * or an existing Net_UserAgent_Mobile_Common object, or a PEAR error object
+ * on error
* @see Net_UserAgent_Mobile::factory()
*/
function &singleton($userAgent = null)
@@ -212,15 +211,16 @@
// {{{ isError()
/**
- * tell whether a result code from a Net_UserAgent_Mobile method
- * is an error
+ * tell whether a result code from a Net_UserAgent_Mobile method is an error
*
* @param integer $value result code
* @return boolean whether $value is an {@link Net_UserAgent_Mobile_Error}
*/
function isError($value)
{
- return is_a($value, 'Net_UserAgent_Mobile_Error');
+ return is_object($value)
+ && (strtolower(get_class($value)) == strtolower('Net_UserAgent_Mobile_Error')
+ || is_subclass_of($value, 'Net_UserAgent_Mobile_Error'));
}
// }}}
@@ -230,8 +230,7 @@
* return a textual error message for a Net_UserAgent_Mobile error code
*
* @param integer $value error code
- * @return string error message, or false if the error code was not
- * recognized
+ * @return string error message, or null if the error code was not recognized
*/
function errorMessage($value)
{
@@ -258,8 +257,7 @@
// {{{ isMobile()
/**
- * Checks whether or not the user agent is mobile by a given user agent
- * string.
+ * Checks whether or not the user agent is mobile by a given user agent string.
*
* @param string $userAgent
* @return boolean
@@ -284,8 +282,7 @@
// {{{ isDoCoMo()
/**
- * Checks whether or not the user agent is DoCoMo by a given user agent
- * string.
+ * Checks whether or not the user agent is DoCoMo by a given user agent string.
*
* @param string $userAgent
* @return boolean
@@ -308,8 +305,7 @@
// {{{ isEZweb()
/**
- * Checks whether or not the user agent is EZweb by a given user agent
- * string.
+ * Checks whether or not the user agent is EZweb by a given user agent string.
*
* @param string $userAgent
* @return boolean
@@ -334,8 +330,7 @@
// {{{ isSoftBank()
/**
- * Checks whether or not the user agent is SoftBank by a given user agent
- * string.
+ * Checks whether or not the user agent is SoftBank by a given user agent string.
*
* @param string $userAgent
* @return boolean
@@ -372,8 +367,7 @@
// {{{ isWillcom()
/**
- * Checks whether or not the user agent is Willcom by a given user agent
- * string.
+ * Checks whether or not the user agent is Willcom by a given user agent string.
*
* @param string $userAgent
* @return boolean
@@ -407,13 +401,13 @@
// {{{ Net_UserAgent_Mobile_Error
/**
- * Net_UserAgent_Mobile_Error implements a class for reporting user
- * agent error messages
+ * Net_UserAgent_Mobile_Error implements a class for reporting user agent error
+ * messages
*
* @category Networking
* @package Net_UserAgent_Mobile
* @author KUBO Atsuhiro <[email protected]>
- * @copyright 2003-2007 KUBO Atsuhiro <[email protected]>
+ * @copyright 2003-2008 KUBO Atsuhiro <[email protected]>
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @package_version@
* @since Class available since Release 0.1
@@ -445,13 +439,12 @@
/**
* constructor
*
- * @param mixed $code Net_UserAgent_Mobile error code, or string
- * with error message.
+ * @param mixed $code Net_UserAgent_Mobile error code, or string with error
+ * message.
* @param integer $mode what 'error mode' to operate in
* @param integer $level what error level to use for $mode and
* PEAR_ERROR_TRIGGER
* @param mixed $userinfo additional user/debug info
- * @access public
*/
function Net_UserAgent_Mobile_Error($code = NET_USERAGENT_MOBILE_ERROR,
$mode = PEAR_ERROR_RETURN,
@@ -466,8 +459,7 @@
);
} else {
$this->PEAR_Error("Net_UserAgent_Mobile Error: $code",
- NET_USERAGENT_MOBILE_ERROR, $mode, $level,
- $userinfo
+ NET_USERAGENT_MOBILE_ERROR, $mode, $level, $userinfo
);
}
}