00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00016 class IpRange implements SingleRange
00017 {
00018 private $startIp = null;
00019 private $endIp = null;
00020
00024 public static function create(IpAddress $startIp, IpAddress $endIp)
00025 {
00026 return new self($startIp, $endIp);
00027 }
00028
00029 public function __construct(IpAddress $startIp, IpAddress $endIp)
00030 {
00031 if ($startIp->getLongIp() > $endIp->getLongIp())
00032 throw new WrongArgumentException(
00033 'start ip must be lower than ip end'
00034 );
00035
00036 $this->startIp = $startIp;
00037 $this->endIp = $endIp;
00038 }
00039
00043 public function getStart()
00044 {
00045 return $this->startIp;
00046 }
00047
00051 public function setStart(IpAddress $startIp)
00052 {
00053 $this->startIp = $startIp;
00054
00055 return $this;
00056 }
00057
00061 public function getEnd()
00062 {
00063 return $this->endIp;
00064 }
00065
00069 public function setEnd(IpAddress $endIp)
00070 {
00071 $this->endIp = $endIp;
00072
00073 return $this->endIp;
00074 }
00075
00076 public function contains( $probe)
00077 {
00078 return (
00079 ($this->startIp->getLongIp() <= $probe->getLongIp())
00080 && ($this->endIp->getLongIp() >= $probe->getLongIp())
00081 );
00082 }
00083 }
00084 ?>