[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Service/DeveloperGarden/Request/IpLocation/ -> LocateIPRequest.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   7   * This source file is subject to the new BSD license that is bundled
   8   * with this package in the file LICENSE.txt.
   9   * It is also available through the world-wide-web at this URL:
  10   * http://framework.zend.com/license/new-bsd
  11   * If you did not receive a copy of the license and are unable to
  12   * obtain it through the world-wide-web, please send an email
  13   * to [email protected] so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Service
  17   * @subpackage DeveloperGarden
  18   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20   * @version    $Id$
  21   */
  22  
  23  /**
  24   * @see Zend_Service_DeveloperGarden_Request_RequestAbstract
  25   */
  26  require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
  27  
  28  /**
  29   * @see Zend_Service_DeveloperGarden_IpLocation_IpAddress
  30   */
  31  require_once 'Zend/Service/DeveloperGarden/IpLocation/IpAddress.php';
  32  
  33  /**
  34   * @category   Zend
  35   * @package    Zend_Service
  36   * @subpackage DeveloperGarden
  37   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  38   * @author     Marco Kaiser
  39   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  40   */
  41  class Zend_Service_DeveloperGarden_Request_IpLocation_LocateIPRequest
  42      extends Zend_Service_DeveloperGarden_Request_RequestAbstract
  43  {
  44      /**
  45       * the ip addresses to lookup for
  46       *
  47       * @var Zend_Service_DeveloperGarden_Request_IpLocation_IpAddress
  48       */
  49      public $address = null;
  50  
  51      /**
  52       * the account
  53       *
  54       * @var string
  55       */
  56      public $account = null;
  57  
  58      /**
  59       * constructor give them the environment
  60       *
  61       * @param integer $environment
  62       * @param Zend_Service_DeveloperGarden_IpLocation_IpAddress|array $ip
  63       *
  64       * @return Zend_Service_DeveloperGarden_Request_RequestAbstract
  65       */
  66      public function __construct($environment, $ip = null)
  67      {
  68          parent::__construct($environment);
  69  
  70          if ($ip !== null) {
  71              $this->setIp($ip);
  72          }
  73      }
  74  
  75      /**
  76       * sets new ip or array of ips
  77       *
  78       * @param Zend_Service_DeveloperGarden_IpLocation_IpAddress|array $ip
  79       *
  80       * @return Zend_Service_DeveloperGarden_Request_IpLocation_LocateIPRequest
  81       */
  82      public function setIp($ip)
  83      {
  84          if ($ip instanceof Zend_Service_DeveloperGarden_IpLocation_IpAddress) {
  85              $this->address[] = array(
  86                  'ipType'    => $ip->getVersion(),
  87                  'ipAddress' => $ip->getIp(),
  88              );
  89              return $this;
  90          }
  91  
  92          if (is_array($ip)) {
  93              foreach ($ip as $ipObject) {
  94                  if (!$ipObject instanceof Zend_Service_DeveloperGarden_IpLocation_IpAddress
  95                      && !is_string($ipObject)
  96                  ) {
  97                      require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
  98                      throw new Zend_Service_DeveloperGarden_Request_Exception(
  99                          'Not a valid Ip Address object found.'
 100                      );
 101                  }
 102                  $this->setIp($ipObject);
 103              }
 104              return $this;
 105          }
 106  
 107          if (!is_string($ip)) {
 108              require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
 109              throw new Zend_Service_DeveloperGarden_Request_Exception('Not a valid Ip Address object found.');
 110          }
 111  
 112          return $this->setIp(new Zend_Service_DeveloperGarden_IpLocation_IpAddress($ip));
 113      }
 114  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1