PluginProbe
Depicter — Popup & Slider Builder / 1.2.0
Depicter — Popup & Slider Builder v1.2.0
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / vendor / symfony / console / Helper / Dumper.php

Dumper.php in Depicter — Popup & Slider Builder 1.2.0, at vendor/symfony/console/Helper/Dumper.php

65 lines 2.0 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 the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Console\Helper;
13
14 use Symfony\Component\Console\Output\OutputInterface;
15 use Symfony\Component\VarDumper\Cloner\ClonerInterface;
16 use Symfony\Component\VarDumper\Cloner\VarCloner;
17 use Symfony\Component\VarDumper\Dumper\CliDumper;
18
19 /**
20 * @author Roland Franssen <franssen.roland@gmail.com>
21 */
22 final class Dumper
23 {
24 private $output;
25 private $dumper;
26 private $cloner;
27 private $handler;
28
29 public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null)
30 {
31 $this->output = $output;
32 $this->dumper = $dumper;
33 $this->cloner = $cloner;
34
35 if (class_exists(CliDumper::class)) {
36 $this->handler = function ($var): string {
37 $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
38 $dumper->setColors($this->output->isDecorated());
39
40 return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true));
41 };
42 } else {
43 $this->handler = function ($var): string {
44 switch (true) {
45 case null === $var:
46 return 'null';
47 case true === $var:
48 return 'true';
49 case false === $var:
50 return 'false';
51 case \is_string($var):
52 return '"'.$var.'"';
53 default:
54 return rtrim(print_r($var, true));
55 }
56 };
57 }
58 }
59
60 public function __invoke($var): string
61 {
62 return ($this->handler)($var);
63 }
64 }
65