/** * @param AdviniAdapter $adapter * @param string $value * * @throws Exception * @return void */ public function processValue(AdviniAdapter $adapter, &$value) { while (false !== strpos($value, self::PROCESS_TOKEN)) { // You cannot define these chars: $ { } ( ) $matches = $adapter->matchNextValue($value, self::PROCESS_TOKEN, '( *[^<>]+ *)>>'); $parts = explode(self::TOKEN_DEFAULT_VALUE, trim($matches[1]), 2); $key = $parts[0]; if (true === isset($this->constants[$key])) { $value = str_replace($matches[0], $this->convert($adapter, $this->constants[$key]), $value); } elseif (true === isset($parts[1])) { $value = str_replace($matches[0], $this->convert($adapter, $parts[1]), $value); if (null === $value) { $value = ''; } } else { throw new Exception(sprintf('Cannot found constant <%s>', $key)); } } }