ecommercebox / vocative-polish-firstname
将名字转换为波兰语称呼的组件。波兰语名字称呼变化
1.0.1
2019-05-08 07:09 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ~4.5
README
将名字转换为波兰语称呼的组件
安装
通过将其添加到composer.json中或运行来安装库
composer require "ecommercebox/vocative-polish-firstname:*"
如何使用
创建包含名字的对象,您可以设置编码和可选的"标题"作为参数。名字的第一个字母被转换为大写。
//required $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');
使用默认标题定义获取称呼名字。可选参数$delimiter,默认为空格和标题定义组名称
echo $name->getVocativeString(); // output: Drogi Panie Mariuszu
使用自定义标题定义获取称呼名字。可选参数$delimiter,默认为空格和标题定义组名称
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
测试结果
您可以通过测试文件检查质量: testVocativePolishFirstName
我们使用字典测试。 查看结果!
测试日期:2016-07-11
总字典名称:1704
差异:0
错误百分比:0%
许可证
MIT许可证。有关更多详细信息,请参阅LICENSE文件。