PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.3
Elementor Website Builder – more than just a page builder v3.28.3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / vendor_prefixed / twig / src / Profiler / Dumper / BaseDumper.php

BaseDumper.php in Elementor Website Builder – more than just a page builder 3.28.3, at vendor_prefixed/twig/src/Profiler/Dumper/BaseDumper.php

53 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace ElementorDeps\Twig\Profiler\Dumper;
12
13 use ElementorDeps\Twig\Profiler\Profile;
14 /**
15 * @author Fabien Potencier <fabien@symfony.com>
16 */
17 abstract class BaseDumper
18 {
19 private $root;
20 public function dump(Profile $profile) : string
21 {
22 return $this->dumpProfile($profile);
23 }
24 protected abstract function formatTemplate(Profile $profile, $prefix) : string;
25 protected abstract function formatNonTemplate(Profile $profile, $prefix) : string;
26 protected abstract function formatTime(Profile $profile, $percent) : string;
27 private function dumpProfile(Profile $profile, $prefix = '', $sibling = \false) : string
28 {
29 if ($profile->isRoot()) {
30 $this->root = $profile->getDuration();
31 $start = $profile->getName();
32 } else {
33 if ($profile->isTemplate()) {
34 $start = $this->formatTemplate($profile, $prefix);
35 } else {
36 $start = $this->formatNonTemplate($profile, $prefix);
37 }
38 $prefix .= $sibling ? '' : ' ';
39 }
40 $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
41 if ($profile->getDuration() * 1000 < 1) {
42 $str = $start . "\n";
43 } else {
44 $str = \sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
45 }
46 $nCount = \count($profile->getProfiles());
47 foreach ($profile as $i => $p) {
48 $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
49 }
50 return $str;
51 }
52 }
53