Skip to content

Commit

Permalink
Fix internal deprecations in Faker\Guesser\Name (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnutix authored Nov 21, 2024
1 parent faeb8b3 commit e0ee18e
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/Faker/Guesser/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,152 +26,152 @@ public function guessFormat($name, $size = null)

if (preg_match('/^is[_A-Z]/', $name)) {
return static function () use ($generator) {
return $generator->boolean;
return $generator->boolean();
};
}

if (preg_match('/(_a|A)t$/', $name)) {
return static function () use ($generator) {
return $generator->dateTime;
return $generator->dateTime();
};
}

switch (str_replace('_', '', $name)) {
case 'firstname':
return static function () use ($generator) {
return $generator->firstName;
return $generator->firstName();
};

case 'lastname':
return static function () use ($generator) {
return $generator->lastName;
return $generator->lastName();
};

case 'username':
case 'login':
return static function () use ($generator) {
return $generator->userName;
return $generator->userName();
};

case 'email':
case 'emailaddress':
return static function () use ($generator) {
return $generator->email;
return $generator->email();
};

case 'phonenumber':
case 'phone':
case 'telephone':
case 'telnumber':
return static function () use ($generator) {
return $generator->phoneNumber;
return $generator->phoneNumber();
};

case 'address':
return static function () use ($generator) {
return $generator->address;
return $generator->address();
};

case 'city':
case 'town':
return static function () use ($generator) {
return $generator->city;
return $generator->city();
};

case 'streetaddress':
return static function () use ($generator) {
return $generator->streetAddress;
return $generator->streetAddress();
};

case 'postcode':
case 'zipcode':
return static function () use ($generator) {
return $generator->postcode;
return $generator->postcode();
};

case 'state':
return static function () use ($generator) {
return $generator->state;
return $generator->state();
};

case 'county':
if ($this->generator->locale == 'en_US') {
return static function () use ($generator) {
return sprintf('%s County', $generator->city);
return sprintf('%s County', $generator->city());
};
}

return static function () use ($generator) {
return $generator->state;
return $generator->state();
};

case 'country':
switch ($size) {
case 2:
return static function () use ($generator) {
return $generator->countryCode;
return $generator->countryCode();
};

case 3:
return static function () use ($generator) {
return $generator->countryISOAlpha3;
return $generator->countryISOAlpha3();
};

case 5:
case 6:
return static function () use ($generator) {
return $generator->locale;
return $generator->locale();
};

default:
return static function () use ($generator) {
return $generator->country;
return $generator->country();
};
}

break;

case 'locale':
return static function () use ($generator) {
return $generator->locale;
return $generator->locale();
};

case 'currency':
case 'currencycode':
return static function () use ($generator) {
return $generator->currencyCode;
return $generator->currencyCode();
};

case 'url':
case 'website':
return static function () use ($generator) {
return $generator->url;
return $generator->url();
};

case 'company':
case 'companyname':
case 'employer':
return static function () use ($generator) {
return $generator->company;
return $generator->company();
};

case 'title':
if ($size !== null && $size <= 10) {
return static function () use ($generator) {
return $generator->title;
return $generator->title();
};
}

return static function () use ($generator) {
return $generator->sentence;
return $generator->sentence();
};

case 'body':
case 'summary':
case 'article':
case 'description':
return static function () use ($generator) {
return $generator->text;
return $generator->text();
};
}

Expand Down

0 comments on commit e0ee18e

Please sign in to comment.