Skip to content

Commit

Permalink
Added Account trait and methods for user ID, username MD5
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyrichardson committed Dec 6, 2020
1 parent b536222 commit 4dd34e6
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Entity/MinFraudInsightsRequestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Grayl\Gateway\MinFraud\Entity;

use Grayl\Gateway\Common\Entity\RequestDataAbstract;
use Grayl\Gateway\MinFraud\Traits\MinFraudAccountParametersTrait;
use Grayl\Gateway\MinFraud\Traits\MinFraudBillingParametersTrait;
use Grayl\Gateway\MinFraud\Traits\MinFraudCreditCardParametersTrait;
use Grayl\Gateway\MinFraud\Traits\MinFraudCustomParametersTrait;
Expand All @@ -25,6 +26,7 @@ class MinFraudInsightsRequestData extends RequestDataAbstract
{

// Traits
use MinFraudAccountParametersTrait;
use MinFraudBillingParametersTrait;
use MinFraudCreditCardParametersTrait;
use MinFraudCustomParametersTrait;
Expand Down
15 changes: 15 additions & 0 deletions src/Helper/MinFraudHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,19 @@ public function getEmailAddressTLD ( string $email ): ?string
1 );
}


/**
* Gets an MD5 hash of a username
*
* @param string $username The username itself
*
* @return string
*/
public function getUsernameMD5 ( string $username ): string
{

// Return an MD% hash of the username
return md5( $username );
}

}
70 changes: 70 additions & 0 deletions src/Traits/MinFraudAccountParametersTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Grayl\Gateway\MinFraud\Traits;

use Grayl\Mixin\Common\Entity\KeyedDataBag;

/**
* Trait MinFraudAccountParametersTrait.
* The trait for manipulating MinFraud account parameters in a MinFraudInsightsRequestData entity.
*
* @property KeyedDataBag $account_parameters Omnipay account parameters bag ( key = value format )
* @package Grayl\Gateway\MinFraud
*/
trait MinFraudAccountParametersTrait
{

/**
* Gets the user ID
*
* @return int
*/
public function getUserID (): int
{

// Return it
return $this->account_parameters->getVariable( 'user_id' );
}


/**
* Sets the user ID
*
* @param int $user_id The internal numerical ID of the user
*/
public function setUserID ( int $user_id ): void
{

// Set the user ID
$this->account_parameters->setVariable( 'user_id',
$user_id );
}


/**
* Gets the username MD5
*
* @return string
*/
public function getUsernameMD5 (): string
{

// Return it
return $this->account_parameters->getVariable( 'username_md5' );
}


/**
* Sets the username MD5
*
* @param string $username_md5 An MD5 hash of the username itself
*/
public function setUsernameMD5 ( string $username_md5 ): void
{

// Set the username MD5
$this->account_parameters->setVariable( 'username_md5',
$username_md5 );
}

}

0 comments on commit 4dd34e6

Please sign in to comment.