Skip to content

Commit

Permalink
avoid using fake on production. TIL; fake func cannot be used in PROD…
Browse files Browse the repository at this point in the history
… lol
  • Loading branch information
sethsandaru committed Oct 8, 2023
1 parent d136158 commit f2745ee
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions app/Services/RandomPersonService.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
<?php

namespace App\Services;
use Faker\Factory as FakerFactory;
use Faker\Generator as Faker;
use Faker\Provider\en_US\Address;

class RandomPersonService
{
private Faker $faker;

public function __construct()
{
$this->faker = FakerFactory::create();
}


/**
* Random data for a fake person in US
*
* @TODO: we will implement the other countries soon
*/
public function random(): array
{
$firstName = fake()->firstName();
$lastName = fake()->lastName();
$firstName = $this->faker->firstName();
$lastName = $this->faker->lastName();
$fullName = "$firstName $lastName";
$address = fake()->streetAddress();
$city = fake()->city();
$address = $this->faker->streetAddress();
$city = $this->faker->city();
$zipCode = Address::postcode();
$state = Address::stateAbbr();
$country = 'US';

$creditCard = fake()->creditCardDetails();
$creditCard = $this->faker->creditCardDetails();
$creditCard['name'] = $fullName;
$creditCard['cvc'] = fake()->numberBetween(100, 999);
$creditCard['cvc'] = $this->faker->numberBetween(100, 999);

$banking = [
'IBAN' => fake()->iban('US'),
'IBAN' => $this->faker->iban('US'),
];

return compact(
Expand Down

0 comments on commit f2745ee

Please sign in to comment.