PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.14.6
Independent Analytics – WordPress Analytics Plugin v2.14.6
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / mlocati / ip-lib / src / Range / Single.php
independent-analytics / vendor / mlocati / ip-lib / src / Range Last commit date
AbstractRange.php 1 year ago Pattern.php 1 year ago RangeInterface.php 1 year ago Single.php 1 year ago Subnet.php 1 year ago Type.php 1 year ago
Single.php
220 lines
1 <?php
2
3 namespace IAWPSCOPED\IPLib\Range;
4
5 use IAWPSCOPED\IPLib\Address\AddressInterface;
6 use IAWPSCOPED\IPLib\Address\IPv4;
7 use IAWPSCOPED\IPLib\Address\Type as AddressType;
8 use IAWPSCOPED\IPLib\Factory;
9 use IAWPSCOPED\IPLib\ParseStringFlag;
10 /**
11 * Represents a single address (eg a range that contains just one address).
12 *
13 * @example 127.0.0.1
14 * @example ::1
15 * @internal
16 */
17 class Single extends AbstractRange
18 {
19 /**
20 * @var \IPLib\Address\AddressInterface
21 */
22 protected $address;
23 /**
24 * Initializes the instance.
25 *
26 * @param \IPLib\Address\AddressInterface $address
27 */
28 protected function __construct(AddressInterface $address)
29 {
30 $this->address = $address;
31 }
32 /**
33 * {@inheritdoc}
34 *
35 * @see \IPLib\Range\RangeInterface::__toString()
36 */
37 public function __toString()
38 {
39 return $this->address->__toString();
40 }
41 /**
42 * @deprecated since 1.17.0: use the parseString() method instead.
43 * For upgrading:
44 * - if $supportNonDecimalIPv4 is true, use the ParseStringFlag::IPV4_MAYBE_NON_DECIMAL flag
45 *
46 * @param string|mixed $range
47 * @param bool $supportNonDecimalIPv4
48 *
49 * @return static|null
50 *
51 * @see \IPLib\Range\Single::parseString()
52 * @since 1.10.0 added the $supportNonDecimalIPv4 argument
53 */
54 public static function fromString($range, $supportNonDecimalIPv4 = \false)
55 {
56 return static::parseString($range, ParseStringFlag::MAY_INCLUDE_PORT | ParseStringFlag::MAY_INCLUDE_ZONEID | ($supportNonDecimalIPv4 ? ParseStringFlag::IPV4_MAYBE_NON_DECIMAL : 0));
57 }
58 /**
59 * Try get the range instance starting from its string representation.
60 *
61 * @param string|mixed $range
62 * @param int $flags A combination or zero or more flags
63 *
64 * @return static|null
65 *
66 * @see \IPLib\ParseStringFlag
67 * @since 1.17.0
68 */
69 public static function parseString($range, $flags = 0)
70 {
71 $result = null;
72 $flags = (int) $flags;
73 $address = Factory::parseAddressString($range, $flags);
74 if ($address !== null) {
75 $result = new static($address);
76 }
77 return $result;
78 }
79 /**
80 * Create the range instance starting from an address instance.
81 *
82 * @param \IPLib\Address\AddressInterface $address
83 *
84 * @return static
85 *
86 * @since 1.2.0
87 */
88 public static function fromAddress(AddressInterface $address)
89 {
90 return new static($address);
91 }
92 /**
93 * {@inheritdoc}
94 *
95 * @see \IPLib\Range\RangeInterface::toString()
96 */
97 public function toString($long = \false)
98 {
99 return $this->address->toString($long);
100 }
101 /**
102 * {@inheritdoc}
103 *
104 * @see \IPLib\Range\RangeInterface::getAddressType()
105 */
106 public function getAddressType()
107 {
108 return $this->address->getAddressType();
109 }
110 /**
111 * {@inheritdoc}
112 *
113 * @see \IPLib\Range\RangeInterface::getRangeType()
114 */
115 public function getRangeType()
116 {
117 return $this->address->getRangeType();
118 }
119 /**
120 * {@inheritdoc}
121 *
122 * @see \IPLib\Range\RangeInterface::contains()
123 */
124 public function contains(AddressInterface $address)
125 {
126 $result = \false;
127 if ($address->getAddressType() === $this->getAddressType()) {
128 if ($address->toString(\false) === $this->address->toString(\false)) {
129 $result = \true;
130 }
131 }
132 return $result;
133 }
134 /**
135 * {@inheritdoc}
136 *
137 * @see \IPLib\Range\RangeInterface::getStartAddress()
138 */
139 public function getStartAddress()
140 {
141 return $this->address;
142 }
143 /**
144 * {@inheritdoc}
145 *
146 * @see \IPLib\Range\RangeInterface::getEndAddress()
147 */
148 public function getEndAddress()
149 {
150 return $this->address;
151 }
152 /**
153 * {@inheritdoc}
154 *
155 * @see \IPLib\Range\RangeInterface::getComparableStartString()
156 */
157 public function getComparableStartString()
158 {
159 return $this->address->getComparableString();
160 }
161 /**
162 * {@inheritdoc}
163 *
164 * @see \IPLib\Range\RangeInterface::getComparableEndString()
165 */
166 public function getComparableEndString()
167 {
168 return $this->address->getComparableString();
169 }
170 /**
171 * {@inheritdoc}
172 *
173 * @see \IPLib\Range\RangeInterface::asSubnet()
174 */
175 public function asSubnet()
176 {
177 $networkPrefixes = array(AddressType::T_IPv4 => 32, AddressType::T_IPv6 => 128);
178 return new Subnet($this->address, $this->address, $networkPrefixes[$this->address->getAddressType()]);
179 }
180 /**
181 * {@inheritdoc}
182 *
183 * @see \IPLib\Range\RangeInterface::asPattern()
184 */
185 public function asPattern()
186 {
187 return new Pattern($this->address, $this->address, 0);
188 }
189 /**
190 * {@inheritdoc}
191 *
192 * @see \IPLib\Range\RangeInterface::getSubnetMask()
193 */
194 public function getSubnetMask()
195 {
196 if ($this->getAddressType() !== AddressType::T_IPv4) {
197 return null;
198 }
199 return IPv4::fromBytes(array(255, 255, 255, 255));
200 }
201 /**
202 * {@inheritdoc}
203 *
204 * @see \IPLib\Range\RangeInterface::getReverseDNSLookupName()
205 */
206 public function getReverseDNSLookupName()
207 {
208 return array($this->getStartAddress()->getReverseDNSLookupName());
209 }
210 /**
211 * {@inheritdoc}
212 *
213 * @see \IPLib\Range\RangeInterface::getSize()
214 */
215 public function getSize()
216 {
217 return 1;
218 }
219 }
220