/** * {@inheritdoc} */ public function dump(Definition $definition) { if (!$definition instanceof EnvironmentVariableDefinition) { throw new \InvalidArgumentException(sprintf('This definition dumper is only compatible with EnvironmentVariableDefinition objects, %s given', get_class($definition))); } $str = ' variable = ' . $definition->getVariableName(); $str .= PHP_EOL . ' optional = ' . ($definition->isOptional() ? 'yes' : 'no'); if ($definition->isOptional()) { $defaultValue = $definition->getDefaultValue(); if ($defaultValue instanceof DefinitionHelper) { $nestedDefinition = Debug::dumpDefinition($defaultValue->getDefinition('')); $defaultValueStr = $this->indent($nestedDefinition); } else { $defaultValueStr = var_export($defaultValue, true); } $str .= PHP_EOL . ' default = ' . $defaultValueStr; } return sprintf('Environment variable (' . PHP_EOL . '%s' . PHP_EOL . ')', $str); }
/** * {@inheritdoc} */ public function dump(Definition $definition) { if (!$definition instanceof ArrayDefinition) { throw new \InvalidArgumentException(sprintf('This definition dumper is only compatible with ArrayDefinition objects, %s given', get_class($definition))); } $str = '[' . PHP_EOL; foreach ($definition->getValues() as $key => $value) { if (is_string($key)) { $key = "'" . $key . "'"; } $str .= ' ' . $key . ' => '; if ($value instanceof DefinitionHelper) { $nestedDefinition = Debug::dumpDefinition($value->getDefinition('')); $str .= $this->indent($nestedDefinition); } else { $str .= var_export($value, true); } $str .= ',' . PHP_EOL; } $str .= ']'; return $str; }
public static function create(Definition $definition, $message) { return new self(sprintf("%s\nFull definition:\n%s", $message, Debug::dumpDefinition($definition))); }
public static function create(Definition $definition, $message) { return new self(sprintf('%s' . PHP_EOL . 'Full definition:' . PHP_EOL . '%s', $message, Debug::dumpDefinition($definition))); }
public static function create(Definition $definition, $message) { return new self(sprintf("Entry %s cannot be resolved: %s\nDefinition of %s:\n%s", $definition->getName(), $message, $definition->getName(), Debug::dump($definition))); }