option/mac

A class to contain a mac adress

0.5.0 2023-10-16 17:56 UTC

This package is not auto-updated.

Last update: 2024-10-01 20:39: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

Useage

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

License

The GNU Lesser General Public License (LGPL-3.0-or-later). Please see License File for more information.