Пример #1
0
 /**
  * @param string $id
  *
  * @throws NonExistentUniquenessException
  */
 public function delete($id)
 {
     /** @var DeleteResult $result */
     $result = $this->connectToStorage->connect()->deleteOne(['_id' => $id]);
     if ($result->getDeletedCount() === 0) {
         throw new NonExistentUniquenessException();
     }
 }
Пример #2
0
 /**
  * @param string $id
  *
  * @throws NonExistentUniquenessException
  *
  * @return Uniqueness
  */
 public function pick($id)
 {
     /** @var Uniqueness $uniqueness */
     $uniqueness = $this->connectToStorage->connect()->findOne(['_id' => $id]);
     if (is_null($uniqueness)) {
         throw new NonExistentUniquenessException($id);
     }
     return $uniqueness;
 }
Пример #3
0
 /**
  * @param string|null $id
  *
  * @return string The already created id
  */
 public function create($id = null)
 {
     $id = $id ?: uniqid();
     $this->connectToStorage->connect()->insertOne(new Uniqueness($id));
     return $id;
 }
Пример #4
0
 /**
  * Computes uniquenesses.
  *
  * @return int
  */
 public function compute()
 {
     return $this->connectToStorage->connect()->count();
 }
Пример #5
0
 /**
  * @return Uniquenesses
  */
 public function collect()
 {
     $uniquenesses = new Uniquenesses($this->connectToStorage->connect()->find());
     return $uniquenesses;
 }