PHP code example of alexivanou / russian-text-bundle
1. Go to this page and download the library: Download alexivanou/russian-text-bundle 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/ */
use AlexIvanou\RussianTextBundle\Service\Pluralizer;
use AlexIvanou\RussianTextBundle\Service\NumberSpeller;
use AlexIvanou\RussianTextBundle\Service\NameInflector;
use AlexIvanou\RussianTextBundle\Service\NounDecliner;
use AlexIvanou\RussianTextBundle\Service\MoneySpeller;
use AlexIvanou\RussianTextBundle\Service\TimeSpeller;
$pluralizer = new Pluralizer();
echo $pluralizer->pluralize('дом', 5); // домов
$numberSpeller = new NumberSpeller();
echo $numberSpeller->cardinal(123); // сто двадцать три
$nameInflector = new NameInflector();
echo $nameInflector->inflect('Иванов Иван', 'творительный'); // Ивановым Иваном
$nounDecliner = new NounDecliner();
echo $nounDecliner->decline('дом', 'родительный'); // дома
$adjDecliner = new AdjectiveDecliner();
echo $adjDecliner->decline('новый', 'родительный'); // нового
$geoInflector = new GeographicalNameInflector();
echo $geoInflector->inflect('Москва', 'родительный'); // Москвы
$moneySpeller = new MoneySpeller();
echo $moneySpeller->spell(123.45, MoneySpeller::RUBLE); // сто двадцать три рубля сорок пять копеек
$timeSpeller = new TimeSpeller();
echo $timeSpeller->timeAgo(new \DateTime('-5 minutes')); // 5 минут назад
use AlexIvanou\RussianTextBundle\Service\PluralizerInterface;
class MyService
{
public function __construct(PluralizerInterface $pluralizer)
{
// ...
}
}
namespace App\Validator;
use AlexIvanou\RussianTextBundle\Service\ValidationRuleInterface;
class PassportUaValidator implements ValidationRuleInterface
{
public function getType() { return 'passport_ua'; }
public function isValid($value) { /* ... */ }
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.