/**
  * Decrease the number of distributed to a user rewards.
  *
  * @param Transaction $transaction
  * @param Reward|null $reward
  *
  * @throws  \RuntimeException
  * @throws  \InvalidArgumentException
  * @throws  \UnexpectedValueException
  *
  * @return void
  */
 protected function decreaseDistributedReward(Transaction $transaction, $reward)
 {
     // Check for valid reward.
     if ($reward === null or !$reward->getId()) {
         return;
     }
     // Check for valida amount between reward value and payed by user
     $txnAmount = $transaction->getAmount();
     if ($txnAmount < $reward->getAmount()) {
         return;
     }
     // Decrease the number of distributed rewards.
     $reward->decreaseDistributed();
     $reward->updateDistributed();
 }