Platformsh\Cli\Util\PropertyFormatter::format PHP Method

format() public method

public format ( mixed $value, string $property = null ) : string
$value mixed
$property string
return string
    public function format($value, $property = null)
    {
        switch ($property) {
            case 'http_access':
                return $this->formatHttpAccess($value);
            case 'token':
                return '******';
            case 'created_at':
            case 'updated_at':
            case 'ssl.expires_on':
                return $this->formatDate($value);
            case 'ssl':
                if ($property === 'ssl' && is_array($value) && isset($value['expires_on'])) {
                    $value['expires_on'] = $this->formatDate($value['expires_on']);
                }
        }
        if (!is_string($value)) {
            $value = rtrim(Yaml::dump($value, $this->yamlInline));
        }
        return $value;
    }

Usage Example

 /**
  * @param string          $property
  * @param string          $value
  * @param Environment     $environment
  *
  * @return int
  */
 protected function setProperty($property, $value, Environment $environment)
 {
     if (!$this->validateValue($property, $value)) {
         return 1;
     }
     $type = $this->getType($property);
     if ($type === 'boolean' && $value === 'false') {
         $value = false;
     }
     settype($value, $type);
     $currentValue = $environment->getProperty($property, false);
     if ($currentValue === $value) {
         $this->stdErr->writeln("Property <info>{$property}</info> already set as: " . $this->formatter->format($environment->getProperty($property, false), $property));
         return 0;
     }
     $environment->update(array($property => $value));
     $this->stdErr->writeln("Property <info>{$property}</info> set to: " . $this->formatter->format($environment[$property], $property));
     $rebuildProperties = array('enable_smtp', 'restrict_robots');
     if (in_array($property, $rebuildProperties) && !$environment->getLastActivity()) {
         $this->rebuildWarning();
     }
     // Refresh the stored environments.
     $this->getEnvironments($this->getSelectedProject(), true);
     return 0;
 }
All Usage Examples Of Platformsh\Cli\Util\PropertyFormatter::format