src/Generator.php
public function getCreditCard($weighted = true)
	{
		// Get a random card type

		if ($weighted) {
			$weight[] = ['American Express', 1];
			$weight[] = ['Discover', 2];
			$weight[] = ['MasterCard', 10];
			$weight[] = ['Visa', 10];
			
			foreach ($weight as $w) {
				$type = $w[0];
				$count = $w[1];
			
				for ($i=0; $i<$count; $i++) {
					$card_types[] = $type;
				}
			}
		} else {
			// @codeCoverageIgnoreStart
			$card_types = ['American Express', 'Discover', 'MasterCard', 'Visa'];
			// @codeCoverageIgnoreEnd
		}

		$cc = new Entities\CreditCard;
				
		$cc->type = $this->fromArray($card_types);

		// Get a random card number appropriate for this type that passes Luhn/Mod10 check
		$cc->number = $this->getBankNumber($cc->type);
		
		// Get an expiration date
		$cc->expiration = $this->getExpiration();

		return $cc;
	}
public function getCreditCard($weighted = true)
	{
		// Get a random card type

		if ($weighted) {
			$weight[] = ['American Express', 1];
			$weight[] = ['Discover', 2];
			$weight[] = ['MasterCard', 10];
			$weight[] = ['Visa', 10];
			
			foreach ($weight as $w) {
				$type = $w[0];
				$count = $w[1];
			
				for ($i=0; $i<$count; $i++) {
					$card_types[] = $type;
				}
			}
		} else {
			// @codeCoverageIgnoreStart
			$card_types = ['American Express', 'Discover', 'MasterCard', 'Visa'];
			// @codeCoverageIgnoreEnd
		}

		$cc = new Entities\CreditCard;
				
		$cc->type = $this->fromArray($card_types);

		// Get a random card number appropriate for this type that passes Luhn/Mod10 check
		$cc->number = $this->getBankNumber($cc->type);
		
		// Get an expiration date
		$cc->expiration = $this->getExpiration();

		return $cc;
	}
public function getCreditCard ( $ weighted = true ) { // Get a random card type if ( $ weighted ) { $ weight [ ] = [ 'American Express' , 1 ] ; $ weight [ ] = [ 'Discover' , 2 ] ; $ weight [ ] = [ 'MasterCard' , 10 ] ; $ weight [ ] = [ 'Visa' , 10 ] ; foreach ( $ weight as $ w ) { $ type = $ w [ 0 ] ; $ count = $ w [ 1 ] ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ card_types [ ] = $ type ; } } } else { // @codeCoverageIgnoreStart $ card_types = [ 'American Express' , 'Discover' , 'MasterCard' , 'Visa' ] ; // @codeCoverageIgnoreEnd } $ cc = new Entities \ CreditCard ; $ cc -> type = $ this -> fromArray ( $ card_types ) ; // Get a random card number appropriate for this type that passes Luhn/Mod10 check $ cc -> number = $ this -> getBankNumber ( $ cc -> type ) ; // Get an expiration date $ cc -> expiration = $ this -> getExpiration ( ) ; return $ cc ; }
Generate a credit card number.

@access public
@param mixed $weighted (default: true) - Make it more likely to return MasterCard or Visa
@return \joshmoody\Mock\Entities\CreditCard
Generate a credit card number .