/** * Deletes the log for given mobile. * * @param string $mobile * * @throws NonExistentMobileInternalException */ public function delete($mobile) { $result = $this->connectToStorageInternalWorker->connect()->remove(array('mobile' => $mobile)); if ($result['n'] == 0) { throw new NonExistentMobileInternalException(); } }
/** * Creates a log for given mobile. * * @param string $mobile * * @throws ExistentMobileInternalException * @throws \MongoCursorException */ public function create($mobile) { try { $this->connectToStorageInternalWorker->connect()->insert(array('mobile' => $mobile)); } catch (\MongoCursorException $e) { if (11000 == $e->getCode()) { throw new ExistentMobileInternalException(); } throw $e; } }
/** * Collects logs. * * @return \Iterator */ public function collect() { return $this->connectToStorageInternalWorker->connect()->find()->fields(['_id' => 0]); }