option / mac
A class to contain a mac adress
0.6.0
2024-11-28 13:53 UTC
Requires
- php: ^8.1
- php-extended/php-mac-interface: 7
Requires (Dev)
- ext-xdebug: ^3.1
- phpunit/phpunit: ^10
This package is not auto-updated.
Last update: 2025-04-01 22:48:17 UTC
README
Read more about MAC adresses: https://en.wikipedia.org/wiki/MAC_address
Supports a good number of input and output formats; hex strings, integer, bytes
Extracts various information about the mac adress:
- isUnicast()
- isMulticast()
- isUniversal()
- isLocal()
Requirements
- PHP >= 8.1
Installation
Via Composer
$ composer require option/mac
Usage
use Option\Mac\Mac; // Any format will do; only hex digits is considered $mac = Mac::factory("1234.5678.90AB"); // Output in various formats: echo $mac; // 01:23:45:67:89:AB echo $mac->asColon(); // 01:23:45:67:89:AB echo $mac->asDot(); // 0123.4567.89AB echo $mac->asIEE802(); // 01-23-45-67-89-AB echo $mac->asDash(); // 01-23-45-67-89-AB // Keep the OUI but zero out the NIC. echo $mac->vendor(); // 01-23-45-00-00-00
Test
$ composer test
A coverage report is generated in coverage/index.html
License
The GNU Lesser General Public License (LGPL-3.0-or-later). Please see License File for more information.