English
1 month ago
Esperanto
1 month ago
French
1 month ago
Italian
1 month ago
NorwegianBokmal
1 month ago
Portuguese
1 month ago
Spanish
1 month ago
Turkish
1 month ago
Pattern.php
1 month ago
Patterns.php
1 month ago
Ruleset.php
1 month ago
Substitution.php
1 month ago
Substitutions.php
1 month ago
Transformation.php
1 month ago
Transformations.php
1 month ago
Word.php
1 month ago
Transformations.php
26 lines
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | namespace IAWPSCOPED\Doctrine\Inflector\Rules; |
| 5 | |
| 6 | use IAWPSCOPED\Doctrine\Inflector\WordInflector; |
| 7 | /** @internal */ |
| 8 | class Transformations implements WordInflector |
| 9 | { |
| 10 | /** @var Transformation[] */ |
| 11 | private $transformations; |
| 12 | public function __construct(Transformation ...$transformations) |
| 13 | { |
| 14 | $this->transformations = $transformations; |
| 15 | } |
| 16 | public function inflect(string $word) : string |
| 17 | { |
| 18 | foreach ($this->transformations as $transformation) { |
| 19 | if ($transformation->getPattern()->matches($word)) { |
| 20 | return $transformation->inflect($word); |
| 21 | } |
| 22 | } |
| 23 | return $word; |
| 24 | } |
| 25 | } |
| 26 |