Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darsyn/ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
https://github.com/darsyn/ip
cidr composer doctrine hacktoberfest immutable ip ip-address ipv4 ipv6 library packagist php rfc value-object
Last synced: about 1 month ago
JSON representation
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
- Host: GitHub
- URL: https://github.com/darsyn/ip
- Owner: darsyn
- License: mit
- Created: 2015-08-22T01:46:37.000Z (over 9 years ago)
- Default Branch: develop
- Last Pushed: 2024-05-10T18:39:48.000Z (7 months ago)
- Last Synced: 2024-05-17T01:42:26.117Z (7 months ago)
- Topics: cidr, composer, doctrine, hacktoberfest, immutable, ip, ip-address, ipv4, ipv6, library, packagist, php, rfc, value-object
- Language: PHP
- Homepage: http://darsyn.github.io/ip/
- Size: 1.25 MB
- Stars: 245
- Watchers: 10
- Forks: 21
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-php - IP - An immutable value object for working with IPv4 and IPv6 addresses. (Table of Contents / Numbers)
- awesome-php-cn - IP - 一个不可变的值对象使用IPv4和IPv6地址. (目录 / 数字 Numbers)
- awesome-projects - IP - An immutable value object for working with IPv4 and IPv6 addresses. (PHP / Numbers)
- awesome-php - IP - An immutable value object for working with IPv4 and IPv6 addresses. (Table of Contents / Numbers)
README
IP is an immutable value object for (both version 4 and 6) IP addresses. Several
helper methods are provided for ranges, broadcast and network addresses, subnet
masks, whether an IP is a certain type (defined by RFC's), etc.This project aims for simplicity of use and any contribution towards that goal -
whether a bug report, modifications to the codebase, or an improvement to the
accuracy or readability of the documentation - are always welcome.# Documentation
Full documentation is available in the [`docs/`](docs/) folder.
## Compatibility
This library has extensive test coverage using PHPUnit on PHP versions: `5.6`,
`7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, and `8.3`.Static analysis is performed with PHPStan at `max` level on PHP `8.3`, using
core, bleeding edge, and deprecation rules.> The Doctrine features for this library have been split off into their own
> package, [`darsyn/ip-doctrine`](https://packagist.org/packages/darsyn/ip-doctrine).## Brief Example
- There are three main classes: [`IPv4`](src/Version/IPv4.php),
[`IPv6`](src/Version/IPv6.php), and [`Multi`](src/Version/Multi.php) (for both
version 4 and 6 addresses).
- Objects are created using a static factory method
[`IpInterface::factory()`](src/IpInterface.php) instead of the constructor to
speed up internal processes.
- When using `Multi`, the default strategy for representing version 4 addresses
internally is [IPv4-mapped](docs/05-strategies.md).```php
inRange($companyNetwork, 25)) {
throw new \Exception('Request not from a known company IP address.');
}// Is it coming from the local network?
if (!$ip->isPrivateUse()) {
record_visit($ip->getBinary(), $_SERVER['HTTP_USER_AGENT']);
}
```## Code of Conduct
This project includes and adheres to the [Contributor Covenant as a Code of
Conduct](CODE_OF_CONDUCT.md).# License
Please see the [separate license file](LICENSE.md) included in this repository
for a full copy of the MIT license, which this project is licensed under.# Authors
- [Zan Baldwin](https://zanbaldwin.com)
- [Jaume Casado Ruiz](http://jau.cat)
- [Pascal Hofmann](http://pascalhofmann.de)If you make a contribution (submit a pull request), don't forget to add your
name here!