DataSift\Storyplayer\CommandLib\SshClient::convertParamsForUse PHP Method

convertParamsForUse() public method

Deprecation:
public convertParamsForUse ( string $params ) : string
$params string
return string
    public function convertParamsForUse($params)
    {
        // vet our input
        Contract::RequiresValue($params, is_string($params));
        // we don't mind if the params are empty
        // our list of what to convert from
        $convertFrom = ['\'', '*'];
        // our list of what to convert to
        $convertTo = ['\\\'', '\'*\''];
        // our return value
        $result = str_replace($convertFrom, $convertTo, $params);
        // all done
        return rtrim($result);
    }

Usage Example

Esempio n. 1
0
 /**
  * @covers DataSift\Storyplayer\CommandLib\SshClient::convertParamsForUse
  */
 public function testCanEscapeParamsForRemoteGlobbing()
 {
     // ----------------------------------------------------------------
     // setup your test
     $i = new Injectables();
     $i->initOutputSupport();
     $i->initDataFormatterSupport();
     $i->initRuntimeConfigSupport($i);
     $st = new StoryTeller($i);
     $obj = new SshClient($st);
     $inputParams = "ls *";
     $expectedParams = "ls '*'";
     // ----------------------------------------------------------------
     // perform the change
     $actualParams = $obj->convertParamsForUse($inputParams);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedParams, $actualParams);
 }