You are here

private function PhpDumper::export in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/dependency-injection/Dumper/PhpDumper.php \Symfony\Component\DependencyInjection\Dumper\PhpDumper::export()
2 calls to PhpDumper::export()
PhpDumper::dumpValue in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Dumps values.
PhpDumper::exportParameters in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Exports parameters.

File

vendor/symfony/dependency-injection/Dumper/PhpDumper.php, line 1539

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function export($value) {
  if (null !== $this->targetDirRegex && is_string($value) && preg_match($this->targetDirRegex, $value, $matches, PREG_OFFSET_CAPTURE)) {
    $prefix = $matches[0][1] ? var_export(substr($value, 0, $matches[0][1]), true) . '.' : '';
    $suffix = $matches[0][1] + strlen($matches[0][0]);
    $suffix = isset($value[$suffix]) ? '.' . var_export(substr($value, $suffix), true) : '';
    $dirname = '__DIR__';
    if (0 < ($offset = 1 + $this->targetDirMaxMatches - count($matches))) {
      $dirname = sprintf('$this->targetDirs[%d]', $offset);
    }
    if ($prefix || $suffix) {
      return sprintf('(%s%s%s)', $prefix, $dirname, $suffix);
    }
    return $dirname;
  }
  return var_export($value, true);
}