<commit_before><?php namespace App\Domain;

use Illuminate\Support\Facades\Log;

class IpnResponder {

  private $ipnDataStore;

  private $verifier;

  public function __construct(
    \App\Domain\IpnDataStore $ipnDataStore,
    \App\Domain\IpnMessageVerifier $verifier
  ) {

    $this->ipnDataStore = $ipnDataStore;
    $this->verifier = $verifier;
  }

  public function verifyIpnMessage($ipnMessage) {

    if($this->ipnMessageisNotFromPaypal($ipnMessage)){
      return false;
    }

    if($this->ipnMessageHasBeenReceivedBefore($ipnMessage)){
      return false;
    }

    $this->saveIpnMessage($ipnMessage);
    
    Log::info(__METHOD__ . ":" . __LINE__ . ": Verified IPN message {$this->get('txn_id', $ipnMessage)}.");

    return true;
  }
  
  private function hasBeenReceivedBefore($ipnMessage) {

    return $this->ipnDataStore->doesMessageExist($ipnMessage);
  }

  public function get($key, $ipnMessage) {
    
    $ipnMessageObject = new IpnMessage();
    $ipnMessageObject->data = $ipnMessage;

    return $ipnMessageObject->data[$key];
  }

  public function getBuyersEmailAddress($ipnMessage) {

    return array_get($ipnMessage, 'payer_email', '');
  }

  public function getItemsPurchased($ipnMessage) {<commit_msg>Not quite the right first step to getting that in there.<commit_after><?php namespace App\Domain;

use Illuminate\Support\Facades\Log;

class IpnResponder {

  private $ipnDataStore;

  private $verifier;

  public function __construct(
    \App\Domain\IpnDataStore $ipnDataStore,
    \App\Domain\IpnMessageVerifier $verifier
  ) {

    $this->ipnDataStore = $ipnDataStore;
    $this->verifier = $verifier;
  }

  public function verifyIpnMessage($ipnMessage) {

    if($this->ipnMessageisNotFromPaypal($ipnMessage)){
      return false;
    }

    if($this->ipnMessageHasBeenReceivedBefore($ipnMessage)){
      return false;
    }

    $this->saveIpnMessage($ipnMessage);
    
    Log::info(__METHOD__ . ":" . __LINE__ . ": Verified IPN message {$this->get('txn_id', $ipnMessage)}.");

    return true;
  }
  
  private function hasBeenReceivedBefore($ipnMessage) {

    return $this->ipnDataStore->doesMessageExist($ipnMessage);
  }

  public function get($key, $ipnMessage) {
    
    return $ipnMessage[$key];
  }

  public function getBuyersEmailAddress($ipnMessage) {

    return array_get($ipnMessage, 'payer_email', '');
  }

  public function getItemsPurchased($ipnMessage) {
{'fraction_non_alphanumeric': 0.1271151465125877, 'fraction_numerical': 0.0, 'mean_word_length': 3.946938775510204, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1975538', 'n_tokens_mistral': 821, 'n_tokens_neox': 793, 'n_words': 137}