Skip to content

Instantly share code, notes, and snippets.

View Tar-Minyatur's full-sized avatar
🏠
Working from home

Till Helge Helwig Tar-Minyatur

🏠
Working from home
View GitHub Profile
@Tar-Minyatur
Tar-Minyatur / IPv4Address.php
Last active June 4, 2016 23:26
This is not necessarily the best implementation to achieve the goal. Using CIDR masks and working with those would probably be more sensible. This code mostly came to life as an example for good code structure.
<?php
/**
* Model of an IPv4 network address.
* Use {@link IPv4Address#fromString} to create an instance.
* Use {@link IPv4Address#isReserved} to check if the address has been reserved
* by IETF or IANA for special purposes and thus is most likely invalid for a
* client connected from outside the local network.
*/
class IPv4Address {