Yii2-morpher

Installation

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock available

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist sevenfloor/yii2-morpher

or add

"sevenfloor/yii2-morpher": "*"

to the require section of your composer.json.

Usage

'components' => [
   // ...
    'morpher' => [
        'class' => 'sevenfloor\morpher\Morpher'
    ]
    // ...
 ]

Get all case;

    Yii::$app->morpher
        ->setQuery('Санкт-Петербург')
    ->getData();

     /*result 
     Array
     (
         [Р] => Санкт-Петербурга
         [Д] => Санкт-Петербургу
         [В] => Санкт-Петербург
         [Т] => Санкт-Петербургом
         [П] => Санкт-Петербурге
         [множественное] => Array
             (
                 [И] => Санкт-Петербурги
                 [Р] => Санкт-Петербургов
                 [Д] => Санкт-Петербургам
                 [В] => Санкт-Петербурги
                 [Т] => Санкт-Петербургами
                 [П] => Санкт-Петербургах
             )
     
     ); */

Get case;

    echo Yii::$app->morpher
        ->setQuery('Санкт-Петербург')
        ->setCase(Morpher::PREPOSITIONAL)
    ->getData();
    //result 'Санкт-Петербурге'

Get plural case;

    echo Yii::$app->morpher
        ->setQuery('Санкт-Петербург')
        ->setCase(Morpher::PREPOSITIONAL)
        ->setPlural()
    ->getData();
    
    //result Санкт-Петербургах