Methods |
public
static
|
formatRange(int|float $from, int|float $to, string $format, string|int|bool|float|null ...$values): string
Inflect placeholders in a string in the singular if a range covers 1
value, or in the plural otherwise
Inflect placeholders in a string in the singular if a range covers 1
value, or in the plural otherwise
For example:
<?php
$message = Inflect::formatRange($from, $to, '{{#:on:from}} {{#:line}} {{#}}');
The word used between $from and $to (default: to ) can be given
explicitly using the following syntax:
<?php
$message = Inflect::formatRange($from, $to, '{{#:at:between}} {{#:value}} {{#:#:and}}');
Parameters
...$values |
Passed to {@see sprintf()}
with the inflected string if given.
|
|
#
|
public
static
|
format(
Arrayable<array-key, mixed>|iterable<array-key, mixed>|Countable|int $count,
string $format,
string|int|bool|float|null ...$values,
): string
Inflect placeholders in a string in the singular if a count is 1, or in
the plural otherwise
Inflect placeholders in a string in the singular if a count is 1, or in
the plural otherwise
For example:
<?php
$message = Inflect::format($count, '{{#}} {{#:entry}} {{#:was}} processed');
The following words are recognised:
# (unconditionally replaced with a number)
no (replaced with a number if $count is not 0 )
a , an (replaced with a number if $count is plural, no if
$count is 0 )
are / is (inflected)
has / have (inflected)
was / were (inflected)
Other words are inflected by {@see Inflect::plural()} if $count is a
value other than 1 , or used without inflection otherwise.
The plural form of a word can be given explicitly using the syntax
{{#:matrix:matrices}} .
Parameters
...$values |
Passed to {@see sprintf()}
with the inflected string if given.
|
|
#
|
public
static
|
formatWithZeroAsOne(
Arrayable<array-key, mixed>|iterable<array-key, mixed>|Countable|int $count,
string $format,
string|int|bool|float|null ...$values,
): string
Inflect placeholders in a string in the singular if a count is 0 or 1, or
in the plural otherwise
Inflect placeholders in a string in the singular if a count is 0 or 1, or
in the plural otherwise
Parameters
...$values |
Passed to {@see sprintf()}
with the inflected string if given.
|
|
#
|
public
static
|
plural(string $word): string
Get the plural form of a singular noun
Get the plural form of a singular noun
|
#
|
public
static
|
indefinite(string $word): string
Get the indefinite article ("a" or "an") to use before a word
Get the indefinite article ("a" or "an") to use before a word
Ported from PERL module Lingua::EN::Inflexion .
|
#
|
public
static
|
list(iterable<string> $words, string $conjunction = 'and', bool $oxford = false, string $separator = ','): string
Use commas and a conjunction to implode a list of words
Use commas and a conjunction to implode a list of words
|
#
|