Documentation

MemoizingInflector
in package
implements InflectorInterface

Decorator used to add memoization to previously inflected words

Interfaces, Classes and Traits

InflectorInterface
Inflector interface used to convert the casing of words

Table of Contents

$cache  : array<string|int, mixed>
$decoratedInflector  : InflectorInterface
$maxCacheSize  : int
__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

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

Return values
mixed

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
string

snake()

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
string

pruneCache()

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

Return values
mixed

Search results