slawap/yii2-morpher

Yii2 Morpher

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Type:yii2-component

1.0.1 2017-06-15 05:39 UTC

This package is not auto-updated.

Last update: 2024-11-01 20:14:35 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 slawap/yii2-morpher

or add

"slawap/yii2-morpher": "*"

to the require section of your composer.json.

Usage

'components' => [
   // ...
    'morpher' => [
        'class' => 'slawap\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 Санкт-Петербургах