1<?php 2 3namespace IPLib\Address; 4 5use IPLib\Range\RangeInterface; 6 7/** 8 * Interface of all the IP address types. 9 */ 10interface AddressInterface 11{ 12 /** 13 * Get the string representation of this address. 14 * 15 * @param bool $long set to true to have a long/full representation, false otherwise 16 * 17 * @return string 18 * 19 * @example If $long is true, you'll get '0000:0000:0000:0000:0000:0000:0000:0001', '::1' otherwise. 20 */ 21 public function toString($long = false); 22 23 /** 24 * Get the short string representation of this address. 25 * 26 * @return string 27 */ 28 public function __toString(); 29 30 /** 31 * Get the byte list of the IP address. 32 * 33 * @return int[] 34 * 35 * @example For IPv4 you'll get array(127, 0, 0, 1), for IPv6 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) 36 */ 37 public function getBytes(); 38 39 /** 40 * Get the type of the IP address. 41 * 42 * @return int One of the \IPLib\Address\Type::T_... constants 43 */ 44 public function getAddressType(); 45 46 /** 47 * Get the default RFC reserved range type. 48 * 49 * @return int One of the \IPLib\Range\Type::T_... constants 50 */ 51 public static function getDefaultReservedRangeType(); 52 53 /** 54 * Get the RFC reserved ranges (except the ones of type getDefaultReservedRangeType). 55 * 56 * @return \IPLib\Address\AssignedRange[] ranges are sorted 57 */ 58 public static function getReservedRanges(); 59 60 /** 61 * Get the type of range of the IP address. 62 * 63 * @return int One of the \IPLib\Range\Type::T_... constants 64 */ 65 public function getRangeType(); 66 67 /** 68 * Get a string representation of this address than can be used when comparing addresses and ranges. 69 * 70 * @return string 71 */ 72 public function getComparableString(); 73 74 /** 75 * Check if this address is contained in an range. 76 * 77 * @param \IPLib\Range\RangeInterface $range 78 * 79 * @return bool 80 */ 81 public function matches(RangeInterface $range); 82 83 /** 84 * Get the address right after this IP address (if available). 85 * 86 * @return \IPLib\Address\AddressInterface|null 87 */ 88 public function getNextAddress(); 89 90 /** 91 * Get the address right before this IP address (if available). 92 * 93 * @return \IPLib\Address\AddressInterface|null 94 */ 95 public function getPreviousAddress(); 96} 97