Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
}