diff --git a/src/Date/DateInterval.php b/src/Date/DateInterval.php index cdf4bbe..1eac6a2 100644 --- a/src/Date/DateInterval.php +++ b/src/Date/DateInterval.php @@ -159,7 +159,7 @@ public static function fromString($string) * * @return bool */ - public function equal(DateInterval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -183,7 +183,7 @@ public function contains(\DateTime $point) * * @return bool */ - public function intersects(DateInterval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -195,7 +195,7 @@ public function intersects(DateInterval $interval) * * @return self|null */ - public function intersection(DateInterval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -207,7 +207,7 @@ public function intersection(DateInterval $interval) * * @return self */ - public function cover(DateInterval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -219,7 +219,7 @@ public function cover(DateInterval $interval) * * @return self|null */ - public function gap(DateInterval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -231,7 +231,7 @@ public function gap(DateInterval $interval) * * @return bool */ - public function abuts(DateInterval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -243,7 +243,7 @@ public function abuts(DateInterval $interval) * * @return self|null */ - public function join(DateInterval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -255,7 +255,7 @@ public function join(DateInterval $interval) * * @return self|null */ - public function union(DateInterval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/DateTime/DateTimeInterval.php b/src/DateTime/DateTimeInterval.php index 835b039..d1e6b0a 100644 --- a/src/DateTime/DateTimeInterval.php +++ b/src/DateTime/DateTimeInterval.php @@ -159,7 +159,7 @@ public static function fromString($string) * * @return bool */ - public function equal(DateTimeInterval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -183,7 +183,7 @@ public function contains(\DateTime $point) * * @return bool */ - public function intersects(DateTimeInterval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -195,7 +195,7 @@ public function intersects(DateTimeInterval $interval) * * @return self|null */ - public function intersection(DateTimeInterval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -207,7 +207,7 @@ public function intersection(DateTimeInterval $interval) * * @return self */ - public function cover(DateTimeInterval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -219,7 +219,7 @@ public function cover(DateTimeInterval $interval) * * @return self|null */ - public function gap(DateTimeInterval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -231,7 +231,7 @@ public function gap(DateTimeInterval $interval) * * @return bool */ - public function abuts(DateTimeInterval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -243,7 +243,7 @@ public function abuts(DateTimeInterval $interval) * * @return self|null */ - public function join(DateTimeInterval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -255,7 +255,7 @@ public function join(DateTimeInterval $interval) * * @return self|null */ - public function union(DateTimeInterval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/IPv4/IPv4Interval.php b/src/IPv4/IPv4Interval.php index f8fb5df..17ccf3b 100644 --- a/src/IPv4/IPv4Interval.php +++ b/src/IPv4/IPv4Interval.php @@ -156,7 +156,7 @@ public static function fromString($string) * * @return bool */ - public function equal(IPv4Interval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -180,7 +180,7 @@ public function contains($point) * * @return bool */ - public function intersects(IPv4Interval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -192,7 +192,7 @@ public function intersects(IPv4Interval $interval) * * @return self|null */ - public function intersection(IPv4Interval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -204,7 +204,7 @@ public function intersection(IPv4Interval $interval) * * @return self */ - public function cover(IPv4Interval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -216,7 +216,7 @@ public function cover(IPv4Interval $interval) * * @return self|null */ - public function gap(IPv4Interval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -228,7 +228,7 @@ public function gap(IPv4Interval $interval) * * @return bool */ - public function abuts(IPv4Interval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -240,7 +240,7 @@ public function abuts(IPv4Interval $interval) * * @return self|null */ - public function join(IPv4Interval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -252,7 +252,7 @@ public function join(IPv4Interval $interval) * * @return self|null */ - public function union(IPv4Interval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/IPv4Network/IPv4Network.php b/src/IPv4Network/IPv4Network.php index d2ccaf4..a1833bc 100644 --- a/src/IPv4Network/IPv4Network.php +++ b/src/IPv4Network/IPv4Network.php @@ -120,7 +120,7 @@ public static function fromString($string) * * @return bool */ - public function equal(IPv4Network $network) + public function equal(self $network) { return $this->comparator->equal($network); } @@ -144,7 +144,7 @@ public function contains($point) * * @return bool */ - public function intersects(IPv4Network $network) + public function intersects(self $network) { return $this->comparator->intersects($network); } @@ -156,7 +156,7 @@ public function intersects(IPv4Network $network) * * @return bool */ - public function abuts(IPv4Network $network) + public function abuts(self $network) { return $this->comparator->abuts($network); } diff --git a/src/IPv4Network/IPv4NetworkMask.php b/src/IPv4Network/IPv4NetworkMask.php index 3323e53..084ceb5 100644 --- a/src/IPv4Network/IPv4NetworkMask.php +++ b/src/IPv4Network/IPv4NetworkMask.php @@ -108,7 +108,7 @@ public function cidr() * * @return bool */ - public function equal(IPv4NetworkMask $mask) + public function equal(self $mask) { return $this->long == $mask->ip(); } diff --git a/src/IPv6/IPv6Interval.php b/src/IPv6/IPv6Interval.php index 8a587bb..133f0fb 100644 --- a/src/IPv6/IPv6Interval.php +++ b/src/IPv6/IPv6Interval.php @@ -144,6 +144,7 @@ public static function fromString($string) { if (!preg_match(self::REGEXP, $string, $match)) { $ipv6 = implode(':', array_fill(0, 8, 'ffff')); + throw InvalidIntervalFormatException::create(sprintf('[%s, %s]', $ipv6, $ipv6), $string); } @@ -157,7 +158,7 @@ public static function fromString($string) * * @return bool */ - public function equal(IPv6Interval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -181,7 +182,7 @@ public function contains($point) * * @return bool */ - public function intersects(IPv6Interval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -193,7 +194,7 @@ public function intersects(IPv6Interval $interval) * * @return self|null */ - public function intersection(IPv6Interval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -205,7 +206,7 @@ public function intersection(IPv6Interval $interval) * * @return self */ - public function cover(IPv6Interval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -217,7 +218,7 @@ public function cover(IPv6Interval $interval) * * @return self|null */ - public function gap(IPv6Interval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -229,7 +230,7 @@ public function gap(IPv6Interval $interval) * * @return bool */ - public function abuts(IPv6Interval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -241,7 +242,7 @@ public function abuts(IPv6Interval $interval) * * @return self|null */ - public function join(IPv6Interval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -253,7 +254,7 @@ public function join(IPv6Interval $interval) * * @return self|null */ - public function union(IPv6Interval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/IPv6Network/IPv6Network.php b/src/IPv6Network/IPv6Network.php index c75c3a9..dbf5600 100644 --- a/src/IPv6Network/IPv6Network.php +++ b/src/IPv6Network/IPv6Network.php @@ -117,6 +117,7 @@ public static function fromString($string) { if (!preg_match(self::REGEXP, $string, $match)) { $ipv6 = implode(':', array_fill(0, 8, 'ffff')); + throw InvalidIntervalFormatException::create($ipv6.'/128', $string); } @@ -130,7 +131,7 @@ public static function fromString($string) * * @return bool */ - public function equal(IPv6Network $network) + public function equal(self $network) { return $this->comparator->equal($network); } @@ -154,7 +155,7 @@ public function contains($point) * * @return bool */ - public function intersects(IPv6Network $network) + public function intersects(self $network) { return $this->comparator->intersects($network); } @@ -166,7 +167,7 @@ public function intersects(IPv6Network $network) * * @return bool */ - public function abuts(IPv6Network $network) + public function abuts(self $network) { return $this->comparator->abuts($network); } diff --git a/src/IntervalPointInterface.php b/src/IntervalPointInterface.php index f1e8c17..416eb1b 100644 --- a/src/IntervalPointInterface.php +++ b/src/IntervalPointInterface.php @@ -22,42 +22,42 @@ public function value(); * * @return bool */ - public function eq(IntervalPointInterface $point); + public function eq(self $point); /** * @param IntervalPointInterface $point * * @return bool */ - public function neq(IntervalPointInterface $point); + public function neq(self $point); /** * @param IntervalPointInterface $point * * @return bool */ - public function lt(IntervalPointInterface $point); + public function lt(self $point); /** * @param IntervalPointInterface $point * * @return bool */ - public function lte(IntervalPointInterface $point); + public function lte(self $point); /** * @param IntervalPointInterface $point * * @return bool */ - public function gt(IntervalPointInterface $point); + public function gt(self $point); /** * @param IntervalPointInterface $point * * @return bool */ - public function gte(IntervalPointInterface $point); + public function gte(self $point); /** * @return string diff --git a/src/IntervalType.php b/src/IntervalType.php index 9a051f8..f8203f4 100644 --- a/src/IntervalType.php +++ b/src/IntervalType.php @@ -228,7 +228,7 @@ public static function fromString($string) * * @return bool */ - public function equal(IntervalType $type) + public function equal(self $type) { return $this->type() == $type->type(); } diff --git a/src/Month/MonthInterval.php b/src/Month/MonthInterval.php index 8ab29f9..fa7bb2e 100644 --- a/src/Month/MonthInterval.php +++ b/src/Month/MonthInterval.php @@ -160,7 +160,7 @@ public static function fromString($string) * * @return bool */ - public function equal(MonthInterval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -184,7 +184,7 @@ public function contains(\DateTime $point) * * @return bool */ - public function intersects(MonthInterval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -196,7 +196,7 @@ public function intersects(MonthInterval $interval) * * @return self|null */ - public function intersection(MonthInterval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -208,7 +208,7 @@ public function intersection(MonthInterval $interval) * * @return self */ - public function cover(MonthInterval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -220,7 +220,7 @@ public function cover(MonthInterval $interval) * * @return self|null */ - public function gap(MonthInterval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -232,7 +232,7 @@ public function gap(MonthInterval $interval) * * @return bool */ - public function abuts(MonthInterval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -244,7 +244,7 @@ public function abuts(MonthInterval $interval) * * @return self|null */ - public function join(MonthInterval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -256,7 +256,7 @@ public function join(MonthInterval $interval) * * @return self|null */ - public function union(MonthInterval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/Number/NumberInterval.php b/src/Number/NumberInterval.php index b1a546f..ef0a3f4 100644 --- a/src/Number/NumberInterval.php +++ b/src/Number/NumberInterval.php @@ -156,7 +156,7 @@ public static function fromString($string) * * @return bool */ - public function equal(NumberInterval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -180,7 +180,7 @@ public function contains($point) * * @return bool */ - public function intersects(NumberInterval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -192,7 +192,7 @@ public function intersects(NumberInterval $interval) * * @return self|null */ - public function intersection(NumberInterval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -204,7 +204,7 @@ public function intersection(NumberInterval $interval) * * @return self */ - public function cover(NumberInterval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -216,7 +216,7 @@ public function cover(NumberInterval $interval) * * @return self|null */ - public function gap(NumberInterval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -228,7 +228,7 @@ public function gap(NumberInterval $interval) * * @return bool */ - public function abuts(NumberInterval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -240,7 +240,7 @@ public function abuts(NumberInterval $interval) * * @return self|null */ - public function join(NumberInterval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -252,7 +252,7 @@ public function join(NumberInterval $interval) * * @return self|null */ - public function union(NumberInterval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/Time/TimeInterval.php b/src/Time/TimeInterval.php index 6942639..e948211 100644 --- a/src/Time/TimeInterval.php +++ b/src/Time/TimeInterval.php @@ -160,7 +160,7 @@ public static function fromString($string) * * @return bool */ - public function equal(TimeInterval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -184,7 +184,7 @@ public function contains(\DateTime $point) * * @return bool */ - public function intersects(TimeInterval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -196,7 +196,7 @@ public function intersects(TimeInterval $interval) * * @return self|null */ - public function intersection(TimeInterval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -208,7 +208,7 @@ public function intersection(TimeInterval $interval) * * @return self */ - public function cover(TimeInterval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -220,7 +220,7 @@ public function cover(TimeInterval $interval) * * @return self|null */ - public function gap(TimeInterval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -232,7 +232,7 @@ public function gap(TimeInterval $interval) * * @return bool */ - public function abuts(TimeInterval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -244,7 +244,7 @@ public function abuts(TimeInterval $interval) * * @return self|null */ - public function join(TimeInterval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -256,7 +256,7 @@ public function join(TimeInterval $interval) * * @return self|null */ - public function union(TimeInterval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/Week/WeekInterval.php b/src/Week/WeekInterval.php index e45d6aa..85acda2 100644 --- a/src/Week/WeekInterval.php +++ b/src/Week/WeekInterval.php @@ -160,7 +160,7 @@ public static function fromString($string) * * @return bool */ - public function equal(WeekInterval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -184,7 +184,7 @@ public function contains(\DateTime $point) * * @return bool */ - public function intersects(WeekInterval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -196,7 +196,7 @@ public function intersects(WeekInterval $interval) * * @return self|null */ - public function intersection(WeekInterval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -208,7 +208,7 @@ public function intersection(WeekInterval $interval) * * @return self */ - public function cover(WeekInterval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -220,7 +220,7 @@ public function cover(WeekInterval $interval) * * @return self|null */ - public function gap(WeekInterval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -232,7 +232,7 @@ public function gap(WeekInterval $interval) * * @return bool */ - public function abuts(WeekInterval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -244,7 +244,7 @@ public function abuts(WeekInterval $interval) * * @return self|null */ - public function join(WeekInterval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -256,7 +256,7 @@ public function join(WeekInterval $interval) * * @return self|null */ - public function union(WeekInterval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/src/Year/YearInterval.php b/src/Year/YearInterval.php index 47fb3b5..f06cdfd 100644 --- a/src/Year/YearInterval.php +++ b/src/Year/YearInterval.php @@ -160,7 +160,7 @@ public static function fromString($string) * * @return bool */ - public function equal(YearInterval $interval) + public function equal(self $interval) { return $this->comparator->equal($interval); } @@ -184,7 +184,7 @@ public function contains(\DateTime $point) * * @return bool */ - public function intersects(YearInterval $interval) + public function intersects(self $interval) { return $this->comparator->intersects($interval); } @@ -196,7 +196,7 @@ public function intersects(YearInterval $interval) * * @return self|null */ - public function intersection(YearInterval $interval) + public function intersection(self $interval) { return $this->comparator->intersection($interval); } @@ -208,7 +208,7 @@ public function intersection(YearInterval $interval) * * @return self */ - public function cover(YearInterval $interval) + public function cover(self $interval) { return $this->comparator->cover($interval); } @@ -220,7 +220,7 @@ public function cover(YearInterval $interval) * * @return self|null */ - public function gap(YearInterval $interval) + public function gap(self $interval) { return $this->comparator->gap($interval); } @@ -232,7 +232,7 @@ public function gap(YearInterval $interval) * * @return bool */ - public function abuts(YearInterval $interval) + public function abuts(self $interval) { return $this->comparator->abuts($interval); } @@ -244,7 +244,7 @@ public function abuts(YearInterval $interval) * * @return self|null */ - public function join(YearInterval $interval) + public function join(self $interval) { return $this->comparator->join($interval); } @@ -256,7 +256,7 @@ public function join(YearInterval $interval) * * @return self|null */ - public function union(YearInterval $interval) + public function union(self $interval) { return $this->comparator->union($interval); } diff --git a/tests/IPv6/IPv6IntervalTest.php b/tests/IPv6/IPv6IntervalTest.php index 3880b8a..25b3269 100644 --- a/tests/IPv6/IPv6IntervalTest.php +++ b/tests/IPv6/IPv6IntervalTest.php @@ -66,15 +66,19 @@ public function testFromString($start, $end, $type) switch ($type) { case IntervalType::TYPE_CLOSED: $interval3 = IPv6Interval::closed($start, $end); + break; case IntervalType::TYPE_OPEN: $interval3 = IPv6Interval::open($start, $end); + break; case IntervalType::TYPE_HALF_CLOSED: $interval3 = IPv6Interval::halfClosed($start, $end); + break; case IntervalType::TYPE_HALF_OPEN: $interval3 = IPv6Interval::halfOpen($start, $end); + break; default: // bad interval type $interval3 = null;