Kraken\Util\Support\StringSupport::parametrize PHP Method

parametrize() public static method

Parametrize string using array of params.
public static parametrize ( string $str, string[] $params ) : string
$str string
$params string[]
return string
    public static function parametrize($str, $params)
    {
        $keys = array_keys($params);
        $vals = array_values($params);
        array_walk($keys, function (&$key) {
            $key = '%' . $key . '%';
        });
        return str_replace($keys, $vals, $str);
    }

Usage Example

Example #1
0
 /**
  * @param string $path
  * @return ClientInterface
  */
 public function boot($path)
 {
     $core = (require realpath($path) . '/bootstrap/Console/Client/bootstrap.php');
     $controller = (new ReflectionClass(StringSupport::parametrize($this->controllerClass, $this->params)))->newInstanceArgs(array_merge($this->controllerParams));
     $controller->setCore($core);
     $core->config($controller->internalConfig($core));
     $controller->internalBoot($core);
     $core->boot();
     $controller->internalConstruct($core);
     return $controller;
 }
All Usage Examples Of Kraken\Util\Support\StringSupport::parametrize