/**
  * @param AddressId $addressId
  * @return Address
  */
 public function addressOfId(AddressId $addressId)
 {
     /** @var Result $result */
     $result = $this->repository->query()->where('id', '==', $addressId->getValue())->execute();
     if ($result === false) {
         return null;
     }
     if ($result->count() == 0) {
         return null;
     }
     $encryptedAddress = $this->documentToEncryptedAddress($result->first());
     return $encryptedAddress;
 }
 /**
  * @param Address $address
  * @return bool
  */
 public function equals(Address $address)
 {
     if ($this->id->equals($address->getId())) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * @return array
  */
 public function toArray()
 {
     $entityAsArray = array();
     $entityAsArray['id'] = $this->id->toArray();
     $entityAsArray['walletId'] = $this->walletId->toArray();
     $entityAsArray['address'] = $this->address;
     $entityAsArray['tag'] = $this->tag;
     $entityAsArray['private'] = $this->private;
     $entityAsArray['public'] = $this->public;
     $entityAsArray['wif'] = $this->wif;
     $entityAsArray['callbackUrl'] = $this->callbackUrl;
     $entityAsArray['creationTime'] = clone $this->creationTime;
     return $entityAsArray;
 }
 /**
  * @return AddressId
  * @throws \Exception
  */
 public function nextIdentity()
 {
     $id = strtoupper(str_replace('.', '', uniqid('', true)));
     return AddressId::create($id);
 }