/**
  * {@inheritdoc}
  */
 public function verify($referenceNumber, $data = array())
 {
     if (!array_key_exists('current_asn', $data)) {
         throw new \LogicException('current_asn key does not exist in $data array');
     }
     // Query IRIS to find a Reference of the given value for this Agent.
     // If IRIS did not return a result, apply an invalid reference number constraint.
     $this->searchCriteria->setReferenceNumber($referenceNumber);
     $result = $this->irisReferenceSearchClient->search($data['current_asn'], $this->searchCriteria, 0, 1);
     if (0 == $result->getTotalRecords()) {
         return false;
     }
     // Believe it or not, IRIS may have returned the wrong result.
     // If the user entered 12, meaning to enter 123, IRIS will return all 12* references.
     // Therefore, double check the reference number from IRIS against the one we searched for.
     $result = current($result->getRecords());
     if ($result->getReferenceNumber() != $referenceNumber) {
         return false;
     }
     // Convert the result into a ReferencingApplication model as it contains data that we will want in the session.
     $referencingApplication = $this->getReferencingApplication($result);
     // Put the reference into the session for other subscribers, to prevent duplicate lookups.
     $this->sessionHolder->putReferenceInSession($referencingApplication, $data['current_asn']);
     return true;
 }
 /**
  * Convert the reference number into a RentRecoveryPlusReference object.
  *
  * @param mixed $referenceNumber
  * @return mixed|RentRecoveryPlusReference
  * @throws \LogicException
  */
 public function reverseTransform($referenceNumber)
 {
     // Attempt to retrieve the corresponding applicationUuid from the session.
     if (false === ($referencingApplication = $this->sessionHolder->getReferenceFromSession($referenceNumber, $this->getCurrentAsn()))) {
         return null;
     }
     // Now create (and return) a RentRecoveryPlusReference and set $referencingApplication as its parent
     return $this->createRentRecoveryPlusReference($referencingApplication);
 }
 /**
  * {@inheritdoc}
  */
 public function verify($referenceNumber, $data = array())
 {
     if (!array_key_exists('current_asn', $data)) {
         throw new \LogicException('current_asn key does not exist in $data array');
     }
     $this->status = $this->sessionHolder->getReferenceFromSession($referenceNumber, $data['current_asn'])->getStatus();
     if (ApplicationStatuses::COMPLETE != $this->status) {
         return false;
     }
     return true;
 }
 /**
  * Verify that the number of days between now and date reference was completed does not exceed the limit.
  *
  * {@inheritdoc}
  */
 public function verify($referenceNumber, $data = array())
 {
     if (!array_key_exists('current_asn', $data)) {
         throw new \LogicException('current_asn key does not exist in $data array');
     }
     $reference = $this->sessionHolder->getReferenceFromSession($referenceNumber, $data['current_asn']);
     if (self::MAX_DAYS_ALLOWED < $this->calculateDaysSinceCompletion($reference)) {
         return false;
     }
     return true;
 }
 /**
  * Convert the radio option 'HomeLet Reference' into a specific product name.
  *
  * @param mixed $referenceType
  * @return mixed|null
  */
 public function reverseTransform($referenceType)
 {
     // Only transform if the user selected 'HomeLet Reference', otherwise leave the value as it is.
     if ('HomeLetReference' != $referenceType) {
         return $referenceType;
     }
     if (false === ($references = $this->sessionHolder->getReferencesFromSession($this->getCurrentAsn()))) {
         // User hasn't entered their reference numbers yet, so don't attempt to set the product type on this request.
         return null;
     }
     $possibleReferenceTypes = $this->getReferenceTypes($references);
     return $this->determineReferenceType($possibleReferenceTypes);
 }