Skip to content

ramazancetinkaya/mac-address-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Mac Address Generator Library

License Version

MAC Address Generator is a PHP library that allows you to generate random MAC addresses and provides additional functionality for manipulating them.

Table of Contents

Features

  • Generate random MAC addresses.
  • Validate MAC addresses.
  • Convert MAC addresses to uppercase or lowercase.

Requirements

  • PHP 8 or higher version.

Usage

$generator = new MACAddressGenerator();

// Generate a random MAC address
$macAddress = $generator->generate();
echo "Generated MAC Address: $macAddress\n";

// Validate a MAC address
if ($generator->validate($macAddress)) {
    echo "MAC Address is valid.\n";
} else {
    echo "MAC Address is invalid.\n";
}

// Convert a MAC address to uppercase
$uppercaseMAC = $generator->toUpperCase($macAddress);
echo "Uppercase MAC Address: $uppercaseMAC\n";

// Convert a MAC address to lowercase
$lowercaseMAC = $generator->toLowerCase($macAddress);
echo "Lowercase MAC Address: $lowercaseMAC\n";

generate()

Generates a random MAC address.

Returns: string - The generated MAC address.

validate($macAddress)

Validates a MAC address.

Parameters:

  • $macAddress (string): The MAC address to validate.

Returns: bool - True if the MAC address is valid, false otherwise.

toUpperCase($macAddress)

Converts a MAC address to uppercase.

Parameters:

  • $macAddress (string): The MAC address to convert.

Returns: string - The MAC address in uppercase.

toLowerCase($macAddress)

Converts a MAC address to lowercase.

Parameters:

  • $macAddress (string): The MAC address to convert.

Returns: string - The MAC address in lowercase.

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please create an issue or submit a pull request. Make sure to follow the existing coding style and provide tests for your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Authors

Ramazan Çetinkaya

Copyright

Copyright (c) [2023] [Ramazan Çetinkaya]

Releases

No releases published

Packages

No packages published

Languages