PHP code example of ecommercebox / vocative-polish-firstname
1. Go to this page and download the library: Download ecommercebox/vocative-polish-firstname library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ecommercebox / vocative-polish-firstname example snippets
//input = 'MARIUSZ';
//optional
$encoding = "UTF-8";
//default group ['U' => 'Panie/Pani', 'M' => 'Panie', 'W' => 'Pani'];
//override default group titles
$titles = ['U' => '', 'M' => 'Drogi Panie', 'W' => 'Droga Pani'];
//override or add new exeptions, where W = Woman, M = Man
$exeptions = [
'Ola' => ['W', 'Oluu'],
'Jan' => ['M', 'Janku']
];
//init object
$name = new \ecbox\VocativePolishFirstName($input, $encoding, $titles, $exeptions);
$titles = ['U' => 'Szanowna(y) Pani(e)', 'M' => 'Szanowny Panie', 'W' => 'Szanowna Pani'];
$name->setTitles($titles, 'polite');
echo $name->getVocativeString();
// output: Drogi Panie Mariuszu
echo $name->getVocativeString('polite');
// output: Szanowny Panie Mariuszu
echo $name->getVocativeFirstName();
// output: Mariuszu
echo $name->getDetectedTitle();
// output: Drogi Panie
echo $name->getDetectedTitle('polite');
// output: Szanowny Panie
echo $name->isMale();
// output: true if yes
echo $name->isWoman();
// output: true if yes
$array = $name->getVocativeArray();
// array: ['M', "Mariuszu"];
// where M: Male, W: Woman, U: Unknown