Просмотр файла vendor/doctrine/inflector/lib/Doctrine/Inflector/CachedWordInflector.php

Размер файла: 511B
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace Doctrine\Inflector;
  6.  
  7. class CachedWordInflector implements WordInflector
  8. {
  9. /** @var WordInflector */
  10. private $wordInflector;
  11.  
  12. /** @var string[] */
  13. private $cache = [];
  14.  
  15. public function __construct(WordInflector $wordInflector)
  16. {
  17. $this->wordInflector = $wordInflector;
  18. }
  19.  
  20. public function inflect(string $word): string
  21. {
  22. return $this->cache[$word] ?? $this->cache[$word] = $this->wordInflector->inflect($word);
  23. }
  24. }