/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/I18n
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/I18n/FormatterLocator.php (2864B)
>
*/
protected $registry = [];
/**
* Tracks whether a registry entry has been converted from a
* FQCN to a formatter object.
*
* @var array
*/
protected $converted = [];
/**
* Constructor.
*
* @param array> $registry An array of key-value pairs where the key is the
* formatter name the value is a FQCN for the formatter.
*/
public function __construct(array $registry = [])
{
foreach ($registry as $name => $spec) {
$this->set($name, $spec);
}
}
/**
* Sets a formatter into the registry by name.
*
* @param string $name The formatter name.
* @param class-string<\Cake\I18n\FormatterInterface> $className A FQCN for a formatter.
* @return void
*/
public function set(string $name, string $className): void
{
$this->registry[$name] = $className;
$this->converted[$name] = false;
}
/**
* Gets a formatter from the registry by name.
*
* @param string $name The formatter to retrieve.
* @return \Cake\I18n\FormatterInterface A formatter object.
* @throws \Cake\I18n\Exception\I18nException
*/
public function get(string $name): FormatterInterface
{
if (!isset($this->registry[$name])) {
throw new I18nException("Formatter named `{$name}` has not been registered");
}
if (!$this->converted[$name]) {
/** @var class-string<\Cake\I18n\FormatterInterface> $formatter */
$formatter = $this->registry[$name];
$this->registry[$name] = new $formatter();
$this->converted[$name] = true;
}
/** @var \Cake\I18n\FormatterInterface */
return $this->registry[$name];
}
}