Documentation

VisageAvatarSource extends AvatarSourceBase
in package

Visage avatar source class

Tags
author

Aberdeener

version
2.0.0-pr12
license

MIT

Table of Contents

Properties

$_base_url  : string
Base URL all avatars from this source will add on to.
$_name  : string
$_perspectives_map  : array<string|int, mixed>
A map of `NamelessMC perspective name` => `Avatar source route`, as not all avatar sources will have the same name, and subsequentally route, for each perspective.

Methods

__construct()  : mixed
formatUrl()  : string
Replace placeholders in raw url with uuid and size of requested avatar.
getAvatar()  : string
Get the URL for this users avatar.
getBaseUrl()  : string
Get base url of this avatar source.
getName()  : string
Get the name of this avatar source.
getPerspectives()  : array<string|int, mixed>
Get "NamelessMC names" of supported perspectives for this avatar source.
getRelativePerspective()  : string
Translate NamelessMC perspective name to the relative name for this avatar source.
getUrlToFormat()  : string
Get raw URL with placeholders to format.

Properties

$_base_url

Base URL all avatars from this source will add on to.

protected string $_base_url = ''

$_perspectives_map

A map of `NamelessMC perspective name` => `Avatar source route`, as not all avatar sources will have the same name, and subsequentally route, for each perspective.

protected array<string|int, mixed> $_perspectives_map = []

Methods

formatUrl()

Replace placeholders in raw url with uuid and size of requested avatar.

public formatUrl(string $url_to_format, string $uuid, int $size) : string
Parameters
$url_to_format : string

Raw url to replace placeholders in.

$uuid : string

uuid (or username, yuck!) of avatar to get.

$size : int

Size of avatar image in pixels to get.

Return values
string

Formatted url.

getAvatar()

Get the URL for this users avatar.

public getAvatar(string $uuid, string $perspective[, int $size = 128 ]) : string
Parameters
$uuid : string

UUID of avatar to get.

$perspective : string

Perspective to render avatar with.

$size : int = 128

Size in pixels to render avatar at. Default 128

Return values
string

Compiled URL of avatar image.

getBaseUrl()

Get base url of this avatar source.

public getBaseUrl() : string
Return values
string

Base url of this source.

getName()

Get the name of this avatar source.

public getName() : string
Return values
string

Name of this avatar source.

getPerspectives()

Get "NamelessMC names" of supported perspectives for this avatar source.

public getPerspectives() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array of perspective names.

getRelativePerspective()

Translate NamelessMC perspective name to the relative name for this avatar source.

public getRelativePerspective(string $perspective) : string
Parameters
$perspective : string

NamelessMC perspective name to translate.

Tags
throws
InvalidArgumentException

When an invalid perspective is passed.

Return values
string

Translated perspective name.

getUrlToFormat()

Get raw URL with placeholders to format.

public getUrlToFormat(string $perspective) : string
  • {identifier} = UUID / username
  • {size} = size in pixels.
Parameters
$perspective : string

Perspective to use in url.

Return values
string

URL with placeholders to format.


        
On this page

Search results