class PrettyProfile

This class provides beautiful images of dogs and cats.

Please use only singletons.

Traits

Constants

CAT_AVATAR_URL_PREFIX

URL Prefix for Cat Images.

https://cabinet.companimal.net/avatars/cat/

CAT_AVATAR_COUNT

Total count for Cat images 41

DOG_AVATAR_URL_PREFIX

URL Prefix for Dog Images https://cabinet.companimal.net/avatars/dog/

DEFAULT_BACKGROUND_PREFIX

URL Prefix for a background image.

https://cabinet.companimal.net/avatars/dog/

DOG_AVATAR_COUNT

Total count for Dog images 80

Properties

static protected $instances from  Singleton

Methods

__construct()

Protected class constructor to prevent direct object creation.

void
__clone()

Prevent object cloning

void
__wakeup()

Singletons should not be restorable from strings.

static Singleton
getInstance()

To return new or existing Singleton instance of the class from which it is called.

string
nickname(int $id)

Get a nickname to related dogs and cats.

string
cat(int $id, string|null $size = null)

Retrieve a cat image URL in various sizes.

array
cats(string|null $size = null)

Retrieve all cat images URL in various sizes.

string
dog(int $id, string|null $size = null)

Retrieve a dog image URL in various sizes.

array
dogs(string|null $size = null)

Retrieve all dog images URLs in various sizes.

static string
profileImage(int $id, string|null $image = null, string $animal = 'dog')

This can be used in Laravel Blade.

static string
backgroundImage(string|null $background_image = null)

Retrieve a background image URL.

Details

in Singleton at line 12
protected __construct()

Protected class constructor to prevent direct object creation.

in Singleton at line 19
final protected void __clone()

Prevent object cloning

Return Value

void

in Singleton at line 26
void __wakeup()

Singletons should not be restorable from strings.

Return Value

void

in Singleton at line 37
final static Singleton getInstance()

To return new or existing Singleton instance of the class from which it is called.

As it sets to final it can't be overridden.

Return Value

Singleton

Singleton instance of the class.

at line 80
string nickname(int $id)

Get a nickname to related dogs and cats.

Parameters

int $id

Use a number to create a nickname. It's suggested to use the user ID.

Return Value

string nickname

Examples

PrettyProfile::getInstance()->nickname(393939);
//=> 평범한 네벨룽

at line 127
string cat(int $id, string|null $size = null)

Retrieve a cat image URL in various sizes.

Parameters

int $id

Use a number to create a cat image. It's suggested to use the user ID.

string|null $size

['large', 'medium', 'small', null]. Null value represents the original size.

Return Value

string

The URL of a cat image.

Examples

PrettyProfile::getInstance()->cat(393939);
//=> https://cabinet.companimal.net/avatars/cat/1.png

at line 141
array cats(string|null $size = null)

Retrieve all cat images URL in various sizes.

Parameters

string|null $size

['large', 'medium', 'small', null]. Null value represents the original size.

Return Value

array

The URLs of all cat images.

Examples

PrettyProfile::getInstance()->cats();
//=> ['https://cabinet.companimal.net/avatars/cat/1.png', ...]

at line 159
string dog(int $id, string|null $size = null)

Retrieve a dog image URL in various sizes.

Parameters

int $id

Use a number to create a dog image. It's suggested to use the user ID.

string|null $size

['large', 'medium', 'small', null]. Null value represents the original size.

Return Value

string

The URL of a cat image.

Examples

PrettyProfile::getInstance()->dog(393939);
//=> https://cabinet.companimal.net/avatars/dog/1.png

at line 173
array dogs(string|null $size = null)

Retrieve all dog images URLs in various sizes.

Parameters

string|null $size

['large', 'medium', 'small', null]. Null value represents the original size.

Return Value

array

The URLs of all dog images

Examples

PrettyProfile::getInstance()->dogs();
//=> ['https://cabinet.companimal.net/avatars/dog/1.png', ...]

at line 192
static string profileImage(int $id, string|null $image = null, string $animal = 'dog')

This can be used in Laravel Blade.

Parameters

int $id

Use a number to create a dog image. It's suggested to use the user ID.

string|null $image

Override return value.

string $animal

['dog', 'cat']

Return Value

string

The URL of a dog or a cat image.

Examples

{{ PrettyProfile::profileImage(393939, animal: 'dog') }}
//=> For Laravel Blade

at line 212
static string backgroundImage(string|null $background_image = null)

Retrieve a background image URL.

Parameters

string|null $background_image

URL of the background image.

Return Value

string