Example #1
0
 /**
  * @param string $value
  * @param int    $port
  *
  * @return $this
  * @throws \InvalidArgumentException
  */
 public function add($value, $port = null)
 {
     if ($value == "*") {
         $this->_values[] = "*";
         return $this;
     }
     if (Ipv4::test($value)) {
         $this->_values[] = new Ipv4($value, $port);
         return $this;
     }
     if (Ipv6::test($value)) {
         $this->_values[] = new Ipv6($value, $port);
         return $this;
     }
     throw new \InvalidArgumentException("{$value} is invalid address");
 }