PHP code example of masterweber / petrovich-php

1. Go to this page and download the library: Download masterweber/petrovich-php 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/ */

    

masterweber / petrovich-php example snippets


use Masterweber\Petrovich\Petrovich;
use Masterweber\Petrovich\Petrovich\Loader;
use Masterweber\Petrovich\Petrovich\Ruleset;

$petrovich = new Petrovich(Loader::load('path-to-vendor/cloudloyalty/petrovich-rules/rules.json'));

// Родительный падеж
$lastNameGenitive   = $petrovich->inflectLastName('Пушкин', Ruleset::CASE_GENITIVE, Ruleset::GENDER_MALE); // Пушкина
$firstNameGenitive  = $petrovich->inflectFirstName('Александр', Ruleset::CASE_GENITIVE, Ruleset::GENDER_MALE); // Александра
$middleNameGenitive = $petrovich->inflectMiddleName('Сергеевич', Ruleset::CASE_GENITIVE, Ruleset::GENDER_MALE); // Сергеевича

use Masterweber\Petrovich\Petrovich;
use Masterweber\Petrovich\Petrovich\Loader;
use Masterweber\Petrovich\Petrovich\Ruleset;

$petrovich = new Petrovich(Loader::load('path-to-vendor/cloudloyalty/petrovich-rules/rules.json'));

// Родительный падеж
// Важно! На данный момент, такой порядок обязателен
$fullNameGenitive = $petrovich->inflectFullName('Пушкин Александр Сергеевич', Ruleset::CASE_GENITIVE, Ruleset::GENDER_MALE); // Пушкина Александра Сергеевича

use Masterweber\Petrovich\Petrovich;

echo Petrovich::detectGender('Петровна'); // Petrovich::GENDER_FEMALE