public static function decodeEntity($entity)
{
if (substr($entity, -1) !== ';') {
return $entity;
}
if (substr($entity, 0, 2) === '&#') {
if (strtolower(substr($entity, 2, 1)) === 'x') {
return self::fromHex(substr($entity, 3, -1));
} else {
return self::fromDecimal(substr($entity, 2, -1));
}
}
$name = substr($entity, 1, -1);
if (isset(self::$entitiesByName[$name])) {
return self::$entitiesByName[$name];
}
return $entity;
}