コード例 #1
0
 /**
  * Deletes the profile with given uniqueness.
  *
  * @param string $uniqueness
  *
  * @throws NonExistentProfileException
  */
 public function delete($uniqueness)
 {
     /** @var DeleteResult $result */
     $result = $this->connectToStorage->connect()->deleteOne(['_id' => $uniqueness]);
     if ($result->getDeletedCount() === 0) {
         throw new NonExistentProfileException();
     }
 }
コード例 #2
0
 /**
  * Creates a profile.
  *
  * @param string $uniqueness
  * @param string $email
  *
  * @throws InvalidEmailException
  *
  * @return string
  */
 public function create($uniqueness, $email)
 {
     if (!Validator::email()->validate($email)) {
         throw new InvalidEmailException();
     }
     $uniqueness = $uniqueness ?: uniqid();
     $this->connectToStorage->connect()->insertOne(new Profile($uniqueness, $email));
     return $uniqueness;
 }
コード例 #3
0
 /**
  * Collects profiles.
  *
  * @return Profiles
  */
 public function collect()
 {
     $profiles = new Profiles($this->connectToStorage->connect()->find());
     return $profiles;
 }