Skip to content
PHP Ecosystem
Explore

Avatar

API reference › Debug Core › Helper › Avatar

final classPHPForge\Debug\Helper\Avatar
Sourcesrc/Helper/Avatar.php

Derives stable, deterministic avatar colours and monogram initials from arbitrary identifying strings.

MethodDescriptionDefined by
hueFor() staticReturns a stable hue (0..359) for the given seed, or DEFAULT_HUE when the seed is empty.Avatar
initial() staticReturns the uppercased first character of the given seed, or '?' when the seed is empty.Avatar
public static function hueFor(string $seed): int

Returns a stable hue (0..359) for the given seed, or DEFAULT_HUE when the seed is empty.

Parameters

ParameterTypeDescription
$seedstringIdentifying value used to derive the hue.

Returns

int: Hue in the 0..359 range.

public static function initial(string $seed): string

Returns the uppercased first character of the given seed, or '?' when the seed is empty.

Multibyte-safe: the initial is taken as one character, not one byte.

Parameters

ParameterTypeDescription
$seedstringIdentifying value the monogram is derived from.

Returns

string: Single uppercased character, or '?'.