Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Got 'Unknown formatter "tollFreePhoneNumber"' using es_ES locale #2030

Open
carlos-mora opened this issue Jul 16, 2020 · 1 comment
Open

Comments

@carlos-mora
Copy link

carlos-mora commented Jul 16, 2020

Summary

In a Laravel project, Faker is provided using a config parameter, 'faker_locale', so the dependency is well instantiated. If not set, fallsback to en_US

Tracking the error message, it seems that there is a typo in Faker\Provider\es_ES\PhoneNumber: function is called tollFreeNumber instead of tollFreePhoneNumber

Changing the function's name solves the issue.

Versions

Version
PHP 7.3.18
fzaninotto/faker 1.9.1

Self-enclosed code snippet for reproduction

// file config\app.php
    /*
    |--------------------------------------------------------------------------
    | Facker Locale Configuration
    |--------------------------------------------------------------------------
    |
    | The facker locale determines the default locale that will be used
    | by the generators.
    |
    */

    'faker_locale' => 'es_ES',
// file database\factory\PersonaFactory.php
$factory->define(Persona::class, function (Faker $faker) {
    return [
        'nombre' => $faker->firstName(),
        'apellidos' => $faker->lastName(),
        'siglas' => $faker->title(),
        'email' => $faker->safeEmail(),
	'observaciones' => $faker->paragraph(1, true),
	// ... more attributes ...
    ];
});
// trrying to use it anywhere, even tinker
$sample = factory('App\Models\Persona')->create()

Expected output

=> App\Models\Persona {#3539
     nombre: "Cristina",
     apellidos: "Robledo",
     siglas: "Lic.",
    ...
}

Actual output

InvalidArgumentException with message 'Unknown formatter "tollFreePhoneNumber"'
@carlos-mora
Copy link
Author

carlos-mora commented Jul 16, 2020

I've made a PR #2031 fixing the typo. Test failed because other langauges issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant