/**
  * Processes delivery operations.
  *
  * @throws UnknownStatusInternalException
  */
 public function process()
 {
     $items = $this->connectToStorageInternalWorker->connect()->find()->sort(['created' => 1]);
     foreach ($items as $item) {
         if ($item['status'] == 'Delivered') {
             $name = 'cubalider.sms.delivered';
         } elseif ($item['status'] == 'Not Delivered') {
             $name = 'cubalider.sms.not_delivered';
         } elseif ($item['status'] == 'Buffered') {
             $name = 'cubalider.sms.buffered';
         } else {
             throw new UnknownStatusInternalException($item['status']);
         }
         $this->eventDispatcher->dispatch($name, new DeliveryEvent($item['message']));
         $this->connectToStorageInternalWorker->connect()->remove(['message' => $item['message']]);
     }
 }
 /**
  * Logs a delivery operation.
  *
  * @param string   $id
  * @param string   $status
  * @param int|null $created
  */
 public function log($id, $status, $created)
 {
     $this->connectToStorageInternalWorker->connect()->insert(array('message' => $id, 'status' => $status, 'created' => $created));
 }