UserHandler
extends BaseHandler
in package
Table of Contents
Properties
- $baseUrl : string
- $client : Client
- $credentialService : LastFmCredentialService|null
- $sessionKey : string|null
Methods
- __construct() : mixed
- getLovedTracks() : array<string|int, mixed>
- getRecentTracks() : array<string|int, mixed>
- getTopArtists() : array<string|int, mixed>
- setCredentialService() : void
- Set the credential service for automatic session management
- setSessionKey() : void
- Manually set session key (overrides automatic detection)
- buildQueryParams() : array<string|int, mixed>
- Build query parameters with automatic session key injection
- getSessionKey() : string|null
- Get session key for authenticated requests
- hasValidCredentials() : bool
- Check if current user has valid credentials
- makeRequest() : array<string|int, mixed>
- Make synchronous API request with error handling
- makeRequestAsync() : PromiseInterface
- Make asynchronous API request returning a promise
- requireAuthentication() : bool
- Require authenticated session for the request
Properties
$baseUrl read-only
protected
string
$baseUrl
$client read-only
protected
Client
$client
$credentialService
protected
LastFmCredentialService|null
$credentialService
= null
$sessionKey
protected
string|null
$sessionKey
= null
Methods
__construct()
public
__construct(Client $client, string $baseUrl) : mixed
Parameters
- $client : Client
- $baseUrl : string
getLovedTracks()
public
getLovedTracks([string|null $username = null ][, int $limit = 50 ][, int $page = 1 ]) : array<string|int, mixed>
Parameters
- $username : string|null = null
- $limit : int = 50
- $page : int = 1
Return values
array<string|int, mixed>getRecentTracks()
public
getRecentTracks([string|null $username = null ][, int $limit = 50 ][, int $page = 1 ]) : array<string|int, mixed>
Parameters
- $username : string|null = null
- $limit : int = 50
- $page : int = 1
Return values
array<string|int, mixed>getTopArtists()
public
getTopArtists([string|null $username = null ][, string $period = 'overall' ][, int $limit = 50 ]) : array<string|int, mixed>
Parameters
- $username : string|null = null
- $period : string = 'overall'
- $limit : int = 50
Return values
array<string|int, mixed>setCredentialService()
Set the credential service for automatic session management
public
setCredentialService(LastFmCredentialService $credentialService) : void
Parameters
- $credentialService : LastFmCredentialService
setSessionKey()
Manually set session key (overrides automatic detection)
public
setSessionKey(string|null $sessionKey) : void
Parameters
- $sessionKey : string|null
buildQueryParams()
Build query parameters with automatic session key injection
protected
buildQueryParams(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>getSessionKey()
Get session key for authenticated requests
protected
getSessionKey() : string|null
Return values
string|nullhasValidCredentials()
Check if current user has valid credentials
protected
hasValidCredentials() : bool
Return values
boolmakeRequest()
Make synchronous API request with error handling
protected
makeRequest(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>makeRequestAsync()
Make asynchronous API request returning a promise
protected
makeRequestAsync(array<string|int, mixed> $params) : PromiseInterface
Parameters
- $params : array<string|int, mixed>
Return values
PromiseInterfacerequireAuthentication()
Require authenticated session for the request
protected
requireAuthentication() : bool