/**
  * @covers Lstr\Sprintf\Middleware\InvokableParams::__construct
  * @covers Lstr\Sprintf\Middleware\InvokableParams::getName
  * @covers Lstr\Sprintf\Middleware\InvokableParams::setName
  */
 public function testNameCanBeChanged()
 {
     $name = uniqid();
     $new_name = "{$name}-{$name}";
     $params = new InvokableParams($name, function () {
     }, []);
     $this->assertEquals($name, $params->getName());
     $params->setName($new_name);
     $this->assertEquals($new_name, $params->getName());
 }
Beispiel #2
0
 /**
  * @param InvokableParams $params
  * @return array
  */
 private function getBuiltOptions(InvokableParams $params)
 {
     $values_callback = $params->getValuesCallback();
     $cli_options = $values_callback($params->getName());
     $built_options = [];
     foreach ($cli_options as $option_name => $option_value) {
         $built_options[] = call_user_func($this->option_builder, $option_name, $option_value);
     }
     return $built_options;
 }
 /**
  * @param InvokableParams $params
  */
 protected function process(InvokableParams $params)
 {
     $name = $params->getName();
     $values_callback = $params->getValuesCallback();
     $args = $values_callback($name);
     if (!is_array($args)) {
         $new_args = $this->escapeShellArg($args);
     } else {
         $new_args = [];
         foreach ($args as $key => $value) {
             $new_args[$key] = $this->escapeShellArg($value);
         }
     }
     $params->setValue($new_args);
 }