CachedCollection
in package
implements
CollectionInterface
FinalYes
Cache the collection of devices.
Table of Contents
Interfaces
- CollectionInterface
- Manage a group of devices.
Constants
- CACHE_KEY : mixed = "device-ip-addresses"
Properties
- $cache : CacheInterface
- $collection : CollectionInterface
- $retrieved : bool
Methods
- __construct() : mixed
- Create a new instance.
- addDevice() : $this
- Add a device to this collection.
- addIp() : $this
- Add a device to this collection using its IP address
- clear() : $this
- Remove all devices from this collection.
- getDevices() : array<string|int, DeviceInterface>
- Get all of the devices on the current network
- getLogger() : LoggerInterface
- Get the logger currently in use.
- setLogger() : void
- clearCache() : void
- Remove any cached data we have.
Constants
CACHE_KEY
private
mixed
CACHE_KEY
= "device-ip-addresses"
Properties
$cache
private
CacheInterface
$cache
The cache object to use for finding Sonos devices on the network.
$collection
private
CollectionInterface
$collection
The device collection to actually use.
$retrieved
private
bool
$retrieved
= false
A flag to indicate whether we've retrieved the devices from cache yet or not.
Methods
__construct()
Create a new instance.
public
__construct(CollectionInterface $collection, CacheInterface $cache) : mixed
Parameters
- $collection : CollectionInterface
-
The device collection to actually use
- $cache : CacheInterface
-
The cache object to use
addDevice()
Add a device to this collection.
public
addDevice(DeviceInterface $device) : $this
Parameters
- $device : DeviceInterface
-
The device to add
Return values
$thisaddIp()
Add a device to this collection using its IP address
public
addIp(string $address) : $this
Parameters
- $address : string
-
The IP address of the device to add
Return values
$thisclear()
Remove all devices from this collection.
public
clear() : $this
Return values
$thisgetDevices()
Get all of the devices on the current network
public
getDevices() : array<string|int, DeviceInterface>
Return values
array<string|int, DeviceInterface>getLogger()
Get the logger currently in use.
public
getLogger() : LoggerInterface
Return values
LoggerInterfacesetLogger()
public
setLogger(LoggerInterface $logger) : void
Parameters
- $logger : LoggerInterface
clearCache()
Remove any cached data we have.
private
clearCache() : void