Since: 2023-03-20

class SongResource extends Resource implements SongResourceInterface

Song resource for mapping from melon.com.

Properties

MelonSong $melon
protected array $container from  Resource

Methods

array
toArray()

To get resource as array.

__construct(Melon $melon)

Constructor.

from  Resource
mixed
__get(mixed $name)

Reading data from inaccessible (protected or private) or non-existing properties.

from  Resource
void
offsetSet(mixed $offset, mixed $value)

ArrayAccess implementation.

from  Resource
bool
offsetExists(mixed $offset)

ArrayAccess implementation.

from  Resource
void
offsetUnset(mixed $offset)

ArrayAccess implementation.

from  Resource
mixed
offsetGet(mixed $offset)

ArrayAccess implementation.

from  Resource
static string|null
emptyToNull(string|null $path)

Infer the default image for Melon as null

from  Resource
int
getMelonSongId()

Get the song ID.

string
getTitle()

Get the song title.

int
getAlbumId()

Get the album ID.

string|null
getArtworkImagePath()

Get the artwork image path.

static SongResource
make(MelonSong $melonSong)

Create a new SongResource instance.

Details

at line 22
array toArray()

To get resource as array.

Return Value

array

in Resource at line 31
__construct(Melon $melon)

Constructor.

Parameters

Melon $melon

Melon class instance

in Resource at line 41
mixed __get(mixed $name)

Reading data from inaccessible (protected or private) or non-existing properties.

Parameters

mixed $name

Return Value

mixed

in Resource at line 49
void offsetSet(mixed $offset, mixed $value)

ArrayAccess implementation.

Parameters

mixed $offset
mixed $value

Return Value

void

in Resource at line 61
bool offsetExists(mixed $offset)

ArrayAccess implementation.

Parameters

mixed $offset

Return Value

bool

in Resource at line 69
void offsetUnset(mixed $offset)

ArrayAccess implementation.

Parameters

mixed $offset

Return Value

void

in Resource at line 77
mixed offsetGet(mixed $offset)

ArrayAccess implementation.

Parameters

mixed $offset

Return Value

mixed

in Resource at line 90
static string|null emptyToNull(string|null $path)

Infer the default image for Melon as null

Parameters

string|null $path

The path from Melon.

Return Value

string|null

If it is default image, return null.

Examples

https://cdnimg.melon.co.kr/resource/mobile40/cds/common/image/sns_post_default_500.jpg

at line 35
int getMelonSongId()

Get the song ID.

Return Value

int

at line 43
string getTitle()

Get the song title.

Return Value

string

at line 51
int getAlbumId()

Get the album ID.

Return Value

int

at line 59
string|null getArtworkImagePath()

Get the artwork image path.

Return Value

string|null

at line 75
static SongResource make(MelonSong $melonSong)

Create a new SongResource instance.

Parameters

MelonSong $melonSong

Return Value

SongResource

Examples

$song = SongResource::make(WaterMelon::make(35945927)->getSong());
print $artist->melon_artistid;
// 3114174
print $artist->name;
//=> NewJeans
print $artist->featured_image_path;
//=> https://cdnimg.melon.co.kr/cm2/artistcrop/images/031/14/174/3114174_20231219153524_500.jpg?8d4887c3dea0a5262fe256c1aef2a9d2/melon/resize/100/optimize/90