PHP Classes

File: src/Processors/Traits/HandleDepthTrait.php

Recommend this page to a friend!
  Classes of Rodolfo Berrios Arce   Var-Dump   src/Processors/Traits/HandleDepthTrait.php   Download  
File: src/Processors/Traits/HandleDepthTrait.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Var-Dump
Show the value of a variable in colored way
Author: By
Last change:
Date: 1 month ago
Size: 1,105 bytes
 

Contents

Class file image Download
<?php

/*
 * This file is part of Chevere.
 *
 * (c) Rodolfo Berrios <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace
Chevere\VarDump\Processors\Traits;

use
Chevere\VarDump\Interfaces\VarDumperInterface;
use
Chevere\VarDump\VarDumpable;
use
Chevere\VarDump\VarDumper;

trait
HandleDepthTrait
{
    private
VarDumperInterface $varDumper;

    private
int $depth = 0;

    public function
depth(): int
   
{
        return
$this->depth;
    }

    private function
handleDepth(mixed $variable): void
   
{
       
$deep = $this->depth;
       
// @infection-ignore-all
       
if (is_scalar($variable)) {
            --
$deep;
        }
        (new
VarDumper(
           
$this->varDumper->writer(),
           
$this->varDumper->format(),
            new
VarDumpable($variable),
           
$this->varDumper->objectReferences(),
        ))
            ->
withDepth($deep)
            ->
withIndent($this->varDumper->indent())
            ->
withProcess();
    }
}