| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Doctrine\Inflector\Rules; |
| 6 |
|
| 7 |
use Doctrine\Inflector\WordInflector; |
| 8 |
|
| 9 |
class Transformations implements WordInflector |
| 10 |
{ |
| 11 |
|
| 12 |
private $transformations; |
| 13 |
|
| 14 |
public function __construct(Transformation ...$transformations) |
| 15 |
{ |
| 16 |
$this->transformations = $transformations; |
| 17 |
} |
| 18 |
|
| 19 |
public function inflect(string $word): string |
| 20 |
{ |
| 21 |
foreach ($this->transformations as $transformation) { |
| 22 |
if ($transformation->getPattern()->matches($word)) { |
| 23 |
return $transformation->inflect($word); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
return $word; |
| 28 |
} |
| 29 |
} |