Download the PHP package ramazancetinkaya/color-code-converter without Composer
On this page you can find all versions of the php package ramazancetinkaya/color-code-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ramazancetinkaya/color-code-converter
More information about ramazancetinkaya/color-code-converter
Files in ramazancetinkaya/color-code-converter
Package color-code-converter
Short Description A modern PHP library for converting color codes between RGB, HEX, and HSL color spaces.
License MIT
Homepage https://github.com/ramazancetinkaya/color-code-converter
Informations about the package color-code-converter
Color Code Converter
A powerful, modern, and extensible PHP library for converting color codes between various color spaces, such as RGB, HEX, and HSL. Designed with a focus on readability, scalability, and production readiness, this library is the ultimate solution for color manipulation.
Report a Bug · New Pull Request
⭐ Show Your Support
If you like this project, give it a ⭐ and share it with your network!
Features
✨ Versatile Color Conversions
Effortlessly convert color codes between popular formats:
- 🔄 RGB ↔ HEX
- 🔄 RGB ↔ HSL
- 🔄 HEX ↔ HSL
⚡ Modern PHP Standards
Built with PHP 8+ features for high performance and future-proof compatibility:
- 🏷️ Strict typing (
strict_types=1
) - 🛠️ Fully typed methods
🛡️ Robust Error Handling
- 🔍 Input validation with detailed exceptions
- 🛑 Catch invalid formats before they propagate
🧩 Extensible Architecture
- 📦 Add support for additional color spaces (e.g., CMYK, LAB) with ease
- 🏗️ Modular design for seamless integration
📘 Comprehensive Documentation
- 📝 Fully documented methods with standardized PHPDoc comments
- 📚 Clear usage examples
🌐 Production-Ready
- 🔒 Secure and reliable for real-world applications
- ⚙️ Optimized for maintainability and scalability
Installation
Using Composer
You can install the ColorCode
library using Composer. Run the following command in your terminal:
Manual Installation
Alternatively, download the source code and include it in your project manually.
-
Clone the repository:
- Include the library in your project:
Usage
Here's how you can use the ColorConverter
class:
API Documentation
hexToRgb(string $hexColor): array
Converts a HEX color string to its RGB representation.
- Parameters:
$hexColor
(string): The HEX color string (e.g.,"#FF5733"
,"FF5733"
).
- Returns:
- (array): An RGB array
[R, G, B]
with values between0-255
.
- (array): An RGB array
rgbToHex(array $rgbArray): string
Converts an RGB array to a HEX color string.
- Parameters:
$rgbArray
(array): An array[R, G, B]
with values between0-255
.
- Returns:
- (string): The HEX color string (e.g.,
"#FF5733"
).
- (string): The HEX color string (e.g.,
rgbToHsl(array $rgbArray): array
Converts an RGB array to its HSL representation.
- Parameters:
$rgbArray
(array): An array[R, G, B]
with values between0-255
.
- Returns:
- (array): An HSL array
[H, S, L]
where: H
(Hue):0-360
S
(Saturation):0-100
(%)L
(Lightness):0-100
(%)
- (array): An HSL array
hslToRgb(array $hslArray): array
Converts an HSL array to its RGB representation.
- Parameters:
$hslArray
(array): An array[H, S, L]
where:H
(Hue):0-360
S
(Saturation):0-100
(%)L
(Lightness):0-100
(%)
- Returns:
- (array): An RGB array
[R, G, B]
with values between0-255
.
- (array): An RGB array
Project Structure
Security
This library is designed with security in mind. Input validation and error handling are implemented to prevent misuse. For vulnerabilities, please open an issue.
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
Authors
This project is maintained with ❤️ by:
- Ramazan Çetinkaya - Developer
- GitHub: @ramazancetinkaya
License
This project is licensed under the MIT License. See the LICENSE file for more details.