DebugFormatterHelper.php
2 years ago
DescriptorHelper.php
2 years ago
Dumper.php
2 years ago
FormatterHelper.php
2 years ago
Helper.php
2 years ago
HelperInterface.php
2 years ago
HelperSet.php
2 years ago
InputAwareHelper.php
2 years ago
ProcessHelper.php
2 years ago
ProgressBar.php
2 years ago
ProgressIndicator.php
2 years ago
QuestionHelper.php
2 years ago
SymfonyQuestionHelper.php
2 years ago
Table.php
2 years ago
TableCell.php
2 years ago
TableCellStyle.php
2 years ago
TableRows.php
3 years ago
TableSeparator.php
2 years ago
TableStyle.php
2 years ago
Dumper.php
60 lines
| 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 | namespace IAWP_SCOPED\Symfony\Component\Console\Helper; |
| 12 | |
| 13 | use IAWP_SCOPED\Symfony\Component\Console\Output\OutputInterface; |
| 14 | use IAWP_SCOPED\Symfony\Component\VarDumper\Cloner\ClonerInterface; |
| 15 | use IAWP_SCOPED\Symfony\Component\VarDumper\Cloner\VarCloner; |
| 16 | use IAWP_SCOPED\Symfony\Component\VarDumper\Dumper\CliDumper; |
| 17 | /** |
| 18 | * @author Roland Franssen <franssen.roland@gmail.com> |
| 19 | * @internal |
| 20 | */ |
| 21 | final class Dumper |
| 22 | { |
| 23 | private $output; |
| 24 | private $dumper; |
| 25 | private $cloner; |
| 26 | private $handler; |
| 27 | public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) |
| 28 | { |
| 29 | $this->output = $output; |
| 30 | $this->dumper = $dumper; |
| 31 | $this->cloner = $cloner; |
| 32 | if (\class_exists(CliDumper::class)) { |
| 33 | $this->handler = function ($var) : string { |
| 34 | $dumper = $this->dumper ?? ($this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR)); |
| 35 | $dumper->setColors($this->output->isDecorated()); |
| 36 | return \rtrim($dumper->dump(($this->cloner ?? ($this->cloner = new VarCloner()))->cloneVar($var)->withRefHandles(\false), \true)); |
| 37 | }; |
| 38 | } else { |
| 39 | $this->handler = function ($var) : string { |
| 40 | switch (\true) { |
| 41 | case null === $var: |
| 42 | return 'null'; |
| 43 | case \true === $var: |
| 44 | return 'true'; |
| 45 | case \false === $var: |
| 46 | return 'false'; |
| 47 | case \is_string($var): |
| 48 | return '"' . $var . '"'; |
| 49 | default: |
| 50 | return \rtrim(\print_r($var, \true)); |
| 51 | } |
| 52 | }; |
| 53 | } |
| 54 | } |
| 55 | public function __invoke($var) : string |
| 56 | { |
| 57 | return ($this->handler)($var); |
| 58 | } |
| 59 | } |
| 60 |