DeploymentStrategy::setChange PHP Method

setChange() public method

public setChange ( string $title, string $from, string $to )
$title string
$from string
$to string
    public function setChange($title, $from, $to)
    {
        // Normalise "empty" values into dashes so comparisons are done properly.
        // This means there is no diference between an empty string and a null
        // but "0" is considered to be non-empty.
        if (empty($from) && !strlen($from)) {
            $from = '-';
        }
        if (empty($to) && !strlen($to)) {
            $to = '-';
        }
        return $this->changes[$title] = array('from' => $from, 'to' => $to);
    }

Usage Example

 /**
  * Create a deployment strategy.
  *
  * @param DNEnvironment $environment
  * @param array $options
  *
  * @return DeploymentStrategy
  */
 public function planDeploy(DNEnvironment $environment, $options)
 {
     $strategy = new DeploymentStrategy($environment, $options);
     $currentBuild = $environment->CurrentBuild();
     $currentSha = $currentBuild ? $currentBuild->SHA : '-';
     if ($currentSha !== $options['sha']) {
         $strategy->setChange('Code version', $currentSha, $options['sha']);
     }
     $strategy->setActionTitle('Confirm deployment');
     $strategy->setActionCode('fast');
     $strategy->setEstimatedTime('2');
     return $strategy;
 }