public function flush()
{
if (empty($this->notifications)) {
return false;
}
// for each endpoint server type
$responses = $this->prepareAndSend($this->notifications);
// if multi curl, flush
if ($this->browser->getClient() instanceof MultiCurl) {
/** @var MultiCurl $multiCurl */
$multiCurl = $this->browser->getClient();
$multiCurl->flush();
}
/** @var Response|null $response */
$return = array();
$completeSuccess = true;
foreach ($responses as $i => $response) {
if (!isset($response)) {
$return[] = array('success' => false, 'endpoint' => $this->notifications[$i]->getEndpoint());
$completeSuccess = false;
} elseif (!$response->isSuccessful()) {
$return[] = array('success' => false, 'endpoint' => $this->notifications[$i]->getEndpoint(), 'statusCode' => $response->getStatusCode(), 'headers' => $response->getHeaders(), 'content' => $response->getContent(), 'expired' => in_array($response->getStatusCode(), array(400, 404, 410)));
$completeSuccess = false;
} else {
$return[] = array('success' => true);
}
}
// reset queue
$this->notifications = null;
return $completeSuccess ? true : $return;
}