I have a script to generate a list of names using FakerPHP in different Locales:
<?php
require_once(__DIR__ . "/vendor/autoload.php");
$gen_num = $sortBy = filter_input(INPUT_GET, 'num2gen', FILTER_SANITIZE_NUMBER_INT, array('options' => array('default' => 30, 'min' => 10, 'max' => 300)));
$faker_langs = ['da_DK', 'sv_SE', 'nb_NO', 'fr_FR', 'pl_PL', 'fi_FI', 'en_GB']; //'de_DE',
$fakers = [];
foreach ($faker_langs as $l) {
$fakers[] = FakerFactory::create($l);
}
for ($x = 0; $x < $gen_num; $x++) {
$lang = rand(0, count($faker_langs) - 1);
echo $fakers[$lang]->name() . "n";
}
I want this list to validate full names, but the titles that are generated in Polish and German introduce a lot of noise.
I noticed that the Danish formats do not include titles, but the German and Polish do:
Danish
https://github.com/FakerPHP/Faker/blob/main/src/Faker/Provider/da_DK/Person.php
protected static $maleNameFormats = [
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{middleName}} {{lastName}}',
'{{firstNameMale}} {{middleName}} {{lastName}}',
'{{firstNameMale}} {{middleName}}-{{middleName}} {{lastName}}',
'{{firstNameMale}} {{middleName}} {{middleName}}-{{lastName}}',
];
German
https://github.com/FakerPHP/Faker/blob/main/src/Faker/Provider/de_DE/Person.php
protected static $maleNameFormats = [
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}}-{{lastName}}',
'{{titleMale}} {{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}} {{suffix}}',
'{{titleMale}} {{firstNameMale}} {{lastName}} {{suffix}}',
];
Is it possible to omit the {{titleMale}} and {{suffix}} ordo I have to create a new Provider inherriting the de_DE one and overriding the $maleNameFormats for the languages that have titles in their formatters?