sevenfloor/yii2-morpher

Yii2 Morpher

dev-master 2017-04-13 10:29 UTC

This package is not auto-updated.

Last update: 2024-11-10 03:03:59 UTC


README

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 Санкт-Петербургах