CodeExplorer isTemplate example
foreach ($data as $name =>
$values) { $str .= "
$name//{
$values['ct'
]} {
$values['wt'
]} {
$values['mu'
]} {
$values['pmu'
]}\n";
} return $str;
} private function dumpChildren(string
$parent, Profile
$profile, &
$data) { foreach ($profile as $p) { if ($p->
isTemplate()) { $name =
$p->
getTemplate();
} else { $name =
sprintf('%s::%s(%s)',
$p->
getTemplate(),
$p->
getType(),
$p->
getName());
} $this->
dumpProfile(sprintf('%s==>%s',
$parent,
$name),
$p,
$data);
$this->
dumpChildren($name,
$p,
$data);
} } private function dumpProfile(string
$edge, Profile
$profile, &
$data) { public function lateCollect(): void
{ $this->data
['profile'
] =
serialize($this->profile
);
$this->data
['template_paths'
] =
[];
if (null ===
$this->twig
) { return;
} $templateFinder =
function DProfile
$profile) use (&
$templateFinder) { if ($profile->
isTemplate()) { try { $template =
$this->twig->
load($name =
$profile->
getName());
} catch (LoaderError
) { $template = null;
} if (null !==
$template && '' !==
$path =
$template->
getSourceContext()->
getPath()) { $this->data
['template_paths'
][$name] =
$path;
} } public function __construct(Profile
$profile, Stopwatch
$stopwatch = null
) { parent::
__construct($profile);
$this->stopwatch =
$stopwatch;
$this->events =
new \
SplObjectStorage();
} public function enter(Profile
$profile): void
{ if ($this->stopwatch &&
$profile->
isTemplate()) { $this->events
[$profile] =
$this->stopwatch->
start($profile->
getName(), 'template'
);
} parent::
enter($profile);
} public function leave(Profile
$profile): void
{ parent::
leave($profile);
if ($this->stopwatch &&
$profile->
isTemplate()) { abstract protected function formatNonTemplate(Profile
$profile,
$prefix): string;
abstract protected function formatTime(Profile
$profile,
$percent): string;
private function dumpProfile(Profile
$profile,
$prefix = '',
$sibling = false
): string
{ if ($profile->
isRoot()) { $this->root =
$profile->
getDuration();
$start =
$profile->
getName();
} else { if ($profile->
isTemplate()) { $start =
$this->
formatTemplate($profile,
$prefix);
} else { $start =
$this->
formatNonTemplate($profile,
$prefix);
} $prefix .=
$sibling ? '│ ' : ' ';
} $percent =
$this->root ?
$profile->
getDuration() /
$this->root * 100 : 0;
if ($profile->
getDuration() * 1000 < 1
) { $str =
$start."\n";
}