Yii2-morpher
Installation
, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
composer require --prefer-dist slawap/yii2-morpher
or add, (*4)
"slawap/yii2-morpher": "*"
to the require
section of your composer.json., (*5)
## Usage, (*6)
php
'components' => [
// ...
'morpher' => [
'class' => 'slawap\morpher\Morpher'
]
// ...
]
, (*7)
Get all case;
```php
Yii::$app->morpher
->setQuery('Санкт-Петербург')
->getData();, (*8)
/*result
Array
(
[Р] => Санкт-Петербурга
[Д] => Санкт-Петербургу
[В] => Санкт-Петербург
[Т] => Санкт-Петербургом
[П] => Санкт-Петербурге
[множественное] => Array
(
[И] => Санкт-Петербурги
[Р] => Санкт-Петербургов
[Д] => Санкт-Петербургам
[В] => Санкт-Петербурги
[Т] => Санкт-Петербургами
[П] => Санкт-Петербургах
)
); */
```, (*9)
Get case;
php
echo Yii::$app->morpher
->setQuery('Санкт-Петербург')
->setCase(Morpher::PREPOSITIONAL)
->getData();
//result 'Санкт-Петербурге'
, (*10)
Get plural case;
```php
echo Yii::$app->morpher
->setQuery('Санкт-Петербург')
->setCase(Morpher::PREPOSITIONAL)
->setPlural()
->getData();, (*11)
//result Санкт-Петербургах
```, (*12)