diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Service/DeveloperGarden/Request/IpLocation/LocateIPRequest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Service/DeveloperGarden/Request/IpLocation/LocateIPRequest.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,114 @@ +setIp($ip); + } + } + + /** + * sets new ip or array of ips + * + * @param Zend_Service_DeveloperGarden_IpLocation_IpAddress|array $ip + * + * @return Zend_Service_DeveloperGarden_Request_IpLocation_LocateIPRequest + */ + public function setIp($ip) + { + if ($ip instanceof Zend_Service_DeveloperGarden_IpLocation_IpAddress) { + $this->address[] = array( + 'ipType' => $ip->getVersion(), + 'ipAddress' => $ip->getIp(), + ); + return $this; + } + + if (is_array($ip)) { + foreach ($ip as $ipObject) { + if (!$ipObject instanceof Zend_Service_DeveloperGarden_IpLocation_IpAddress + && !is_string($ipObject) + ) { + require_once 'Zend/Service/DeveloperGarden/Request/Exception.php'; + throw new Zend_Service_DeveloperGarden_Request_Exception( + 'Not a valid Ip Address object found.' + ); + } + $this->setIp($ipObject); + } + return $this; + } + + if (!is_string($ip)) { + require_once 'Zend/Service/DeveloperGarden/Request/Exception.php'; + throw new Zend_Service_DeveloperGarden_Request_Exception('Not a valid Ip Address object found.'); + } + + return $this->setIp(new Zend_Service_DeveloperGarden_IpLocation_IpAddress($ip)); + } +}