Download the PHP package acamposm/ipv4-address-converter without Composer
On this page you can find all versions of the php package acamposm/ipv4-address-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ipv4-address-converter
IPv4 Address Converter
This PHP package allows you to perform IPv4 Address conversion within Laravel applications.
- Features
- Conversions
- Installation
- Usage
- Input methods
- Output methods
- Modifiers
- Sample outputs
- Testing
- Changelog
- Contributing
- Security Vulnerabilities
- Standards
- Credits
- License
Features
The package accepts an IP address as an input and converts it to a specified IP address format.
The input and output can be one of these formats: binary string, dotted decimal, hexadecimal string, or long integer
Conversions
Converts from:
- Binary
- Decimal
- Hexadecimal
- Long
Converts to:
- Binary
- Decimal
- Hexadecimal
- Long
Installation
You can install the package via composer and then publish the assets:
Add the library to your composer.json file:
Or use composer to install the library:
Note: We try to follow SemVer v2.0.0.
Usage
Input Methods
These are the valid input methods for the conversion of the IP Addresses.
fromBinary
Set the input for the IP Address conversion as a binary string.
accepts | string $address |
---|---|
returns | IPv4AddressConverter |
fromDecimal
Set the input for the IP Address conversion as a doted decimal string.
accepts | string $address |
---|---|
returns | IPv4AddressConverter |
fromHexadecimal
Set the input for the IP Address conversion as a hexadecimal string.
accepts | string $address |
---|---|
returns | IPv4AddressConverter |
fromLong
Set the input for the IP Address conversion as a long integer.
accepts | string $address |
---|---|
returns | IPv4AddressConverter |
Output Methods
These methods are valid output methods for the conversion of the IP address specified in the previous input methods.
toBinary
Set binary string as desired output format.
toDecimal
Set dotted decimal as desired output format.
toHexadecimal
Set hexadecimal string as desired output format.
toLong
Set long integer as desired output format.
Modifiers
With these modifiers we can control the output of the conversion operation.
withDotNotation
This modifier will apply dot notation to the output of the conversion, only available to binary strings and hexadecimal strings.
Sample outputs
From Decimal to Long Integer
This example shows how to convert a dotted-decimal IP address to a long integer IP address.
The output of the conversion is a integer.
From Decimal to Binary String
This example shows how to convert a dotted decimal IP address to binary string IP address.
The output is a binary string IP Address.
From Decimal to Binary String with Dot Notation
This example shows how to convert a dotted-decimal IP address to binary string IP address with dot notation.
The output is a binary string IP Address with dot notation.
From Decimal to Hexadecimal
This example shows how to convert a dotted-decimal IP address to a hexadecimal string IP address.
The output of the conversion is a hexadecimal string IP address.
From Decimal to Hexadecimal with Dot Notation
This example shows how to convert a dotted-decimal IP address to a hexadecimal string IP address with dot notation.
The output of the conversion is a hexadecimal string IP address with dot notation.
Output All
There's an all method, that converts an input address to all formats.
The input address for the conversion can be a binary, decimal, hexadecimal or long address.
The output is an object with the address converted to all formats.
Testing
To run the tests you only need to run this command:
Changelog
Please see CHANGELOG.md for more information what has changed recently.
Contributing
Thank you for considering contributing to the improvement of the package. Please see CONTRIBUTING.md for details.
Security Vulnerabilities
If you discover any security related issues, please send an e-mail to Angel Campos via [email protected] instead of using the issue tracker. All security vulnerabilities will be promptly addressed.
Standards
The php package IPv4 Address Converter, comply with the next standards:
Credits
Angel Campos
License
The package IPv4 Address Converter is an open-source package and is licensed under The MIT License (MIT). Please see License File for more information.