* @author Matthias Sommerfeld * @package Net * @version $Id$ */ class Net_IDNA { // {{{ factory /** * Attempts to return a concrete IDNA instance for either php4 or php5. * * @param array $params Set of paramaters * @return object IDNA The newly created concrete Log instance, or an * false on an error. * @access public */ function &getInstance($params = array()) { $version = explode( '.', phpversion() ); $handler = ((int)$version[0] > 4) ? 'php5' : 'php4'; $class = 'Net_IDNA_' . $handler; $classfile = 'Net/IDNA/' . $handler . '.php'; /* * Attempt to include our version of the named class, but don't treat * a failure as fatal. The caller may have already included their own * version of the named class. */ include_once $classfile; /* If the class exists, return a new instance of it. */ if (class_exists($class)) { return new $class($params); } return false; } // }}} // {{{ singleton /** * Attempts to return a concrete IDNA instance for either php4 or php5, * only creating a new instance if no IDNA instance with the same * parameters currently exists. * * @param array $params Set of paramaters * @return object IDNA The newly created concrete Log instance, or an * false on an error. * @access public */ function &singleton($params = array()) { static $instances; if (!isset($instances)) { $instances = array(); } $signature = serialize($params); if (!isset($instances[$signature])) { $instances[$signature] = &Net_IDNA::factory($params); } return $instances[$signature]; } // }}} } ?>