Remove token.
When the class calls this function
private function checkDevicesTokens()
{
$devices = $this->getDevices();
$adapter = $this->getAdapter();
foreach ($devices as $device) {
if (false === $adapter->supports($device->getToken())) {
throw new AdapterException(
sprintf(
'Adapter %s does not support %s token\'s device',
(string) $adapter,
$device->getToken()
)
);
}
}
}
instead of throwing a new exception. Is there a way to just remove the token from the iterator object? And then the script would not die and just cleanse / purge the token list.
This function is not supposed to have a heavy overhead (regarding to the original purpose that it have been developed for). Therefore, I suggest to add an API-function (preferably public function inside the class) that does similar loop to this one, except it must have a flag-check (boolean for "either skip or force to send the push after encountering error") and then do the logic and [if necessary] logging after the original loop-logic.
@aliemam, I agree, but the name is like filterSupportedTokens() and without exception.