PHP code example of staticall / petrovich-php

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

    

staticall / petrovich-php example snippets


mb_internal_encoding('UTF-8');

rovich(Staticall\Petrovich\Loader::load('path-to-vendor/cloudloyalty/petrovich-rules/rules.json'));

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

mb_internal_encoding('UTF-8');

rovich(Staticall\Petrovich\Loader::load('path-to-vendor/cloudloyalty/petrovich-rules/rules.json'));

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

mb_internal_encoding('UTF-8');

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