diff --git a/README.md b/README.md index d5fe14e..b520d18 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ var_dump(morphos\Russian\Plurality::pluralize('дом', 10)); // домов var_dump(morphos\Russian\Plurality::pluralize('гидродендрариум', 2)); // гидродендрариума ``` +Generate russian cardinal numerals: + +```php +var_dump(morphos\Russian\CardinalNumeral::generate(567)); // пятьсот шестьдесят семь +``` + Pluralize english nouns: ```php @@ -351,6 +357,7 @@ All number creation classes are similar and have two common methods: - `string getForm($number, $case, $gender = NumeralCreation::MALE)` - Get one form of a number. - `array getForms($number, $gender = NumeralCreation::MALE)` - Get all forms of a number. +- `string #generate($number, $gender = NumeralCreation::MALE)` - Generates a cardinal numeral for a number. `$gender` is one of `morphos\NumeralCreation` constants: `MALE` or `FEMALE` or `NEUTER`. @@ -399,6 +406,17 @@ var_dump($cardinal->getForms($number)); */ ``` +Generate numeral of a number: + +```php +use morphos\Russian\CardinalNumeral; + +$number = 4351; + +echo CardinalNumeral::generate($number); +// result: четыре тысячи триста пятьдесят один +``` + ## Cases (`Cases`) Cases in russian language: diff --git a/src/Russian/CardinalNumeral.php b/src/Russian/CardinalNumeral.php index 696c095..f2d9bd5 100644 --- a/src/Russian/CardinalNumeral.php +++ b/src/Russian/CardinalNumeral.php @@ -273,4 +273,11 @@ public function getForm($number, $form, $gender = self::MALE) { $forms = $this->getForms($number, $gender); return $forms[$form]; } + + static public function generate($number, $gender = self::MALE) { + static $card; + if ($card === null) $card = new self(); + + return $card->getForm($number, self::IMENIT, $gender); + } }