You are here

public function Exporter::shortenedRecursiveExport in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/sebastian/exporter/src/Exporter.php \SebastianBergmann\Exporter\Exporter::shortenedRecursiveExport()

Parameters

mixed $data:

Context $context:

Return value

string

File

vendor/sebastian/exporter/src/Exporter.php, line 55

Class

Exporter
A nifty utility for visualizing PHP variables.

Namespace

SebastianBergmann\Exporter

Code

public function shortenedRecursiveExport(&$data, Context $context = null) {
  $result = array();
  $exporter = new self();
  if (!$context) {
    $context = new Context();
  }
  $context
    ->add($data);
  foreach ($data as $key => $value) {
    if (is_array($value)) {
      if ($context
        ->contains($data[$key]) !== false) {
        $result[] = '*RECURSION*';
      }
      else {
        $result[] = sprintf('array(%s)', $this
          ->shortenedRecursiveExport($data[$key], $context));
      }
    }
    else {
      $result[] = $exporter
        ->shortenedExport($value);
    }
  }
  return implode(', ', $result);
}