cebe/color-nick

A simple PHP lib that can color nick names to make them distinguishable in a chat room.

1.0.0 2014-10-27 01:18 UTC

This package is auto-updated.

Last update: 2024-11-05 18:54:28 UTC


README

A simple PHP lib that can color nick names to make them distinguishable in a chat room. Each color is unique to the name so each name keeps its color regardless of the time, system or whatever circumstances. This is done using a sha1 hash on the name and taking the first 7 characters in it hex representation to calculate the color.

Latest Stable Version Total Downloads

Requirements

PHP 5.4 or higher.

Installation

Using Composer:

composer require cebe/color-nick

Usage

<?php

use cebe\colornick\Color;

require(__DIR__ . '/vendor/autoload.php');

$color = Color::calculateColor($name);

See example.php for a working example. Here is a screenshot of the output:

Screenshot of color-nick library rendering result

License

MIT, see LICENSE file for more details.