MemoizingInflector
in package
implements
InflectorInterface
Decorator used to add memoization to previously inflected words
Table of Contents
Interfaces
- InflectorInterface
- Inflector interface used to convert the casing of words
Properties
- $cache : array<string|int, mixed>
- $decoratedInflector : InflectorInterface
- $maxCacheSize : int
Methods
- __construct() : mixed
- camel() : string
- Converts strings from snake_case to upper CamelCase
- snake() : string
- Converts strings from camel case to snake case (e.g. CamelCase camel_case).
- pruneCache() : mixed
- Prune one of the named caches by removing 20% of the cache if it is full
Properties
$cache
protected
array<string|int, mixed>
$cache
= array('snake' => array(), 'camel' => array())
Array of cached inflections
$decoratedInflector
protected
InflectorInterface
$decoratedInflector
Decorated inflector
$maxCacheSize
protected
int
$maxCacheSize
Max entries per cache
Methods
__construct()
public
__construct(InflectorInterface $inflector[, int $maxCacheSize = 500 ]) : mixed
Parameters
- $inflector : InflectorInterface
-
Inflector being decorated
- $maxCacheSize : int = 500
-
Maximum number of cached items to hold per cache
camel()
Converts strings from snake_case to upper CamelCase
public
camel(string $word) : string
Parameters
- $word : string
-
Value to convert into upper CamelCase
Return values
stringsnake()
Converts strings from camel case to snake case (e.g. CamelCase camel_case).
public
snake(mixed $word) : string
Parameters
- $word : mixed
-
Word to convert to snake case
Return values
stringpruneCache()
Prune one of the named caches by removing 20% of the cache if it is full
protected
pruneCache(string $cache) : mixed
Parameters
- $cache : string
-
Type of cache to prune