src/Viserio/Bridge/Monolog/Formatter/ConsoleFormatter.php
private function castObjectClass(): object
    {
        return new class($this->options) {
            /**
             * Console formatter configuration.
             *
             * @var array
             */
            private $options;

            public function __construct(array $options)
            {
                $this->options = $options;
            }

            /**
             * @param mixed                                    $value
             * @param array                                    $array
             * @param \Symfony\Component\VarDumper\Cloner\Stub $stub
             * @param mixed                                    $isNested
             *
             * @return array
             */
            public function castObject($value, array $array, Stub $stub, $isNested): array
            {
                if ($this->options['multiline']) {
                    return $array;
                }

                if ($isNested && ! $value instanceof DateTimeInterface) {
                    $stub->cut = -1;
                    $array     = [];
                }

                return $array;
            }
        };
    }
private function castObjectClass(): object
    {
        return new class($this->options) {
            /**
             * Console formatter configuration.
             *
             * @var array
             */
            private $options;

            public function __construct(array $options)
            {
                $this->options = $options;
            }

            /**
             * @param mixed                                    $value
             * @param array                                    $array
             * @param \Symfony\Component\VarDumper\Cloner\Stub $stub
             * @param mixed                                    $isNested
             *
             * @return array
             */
            public function castObject($value, array $array, Stub $stub, $isNested): array
            {
                if ($this->options['multiline']) {
                    return $array;
                }

                if ($isNested && ! $value instanceof DateTimeInterface) {
                    $stub->cut = -1;
                    $array     = [];
                }

                return $array;
            }
        };
    }
Return a anonymous class with a castObject function.

@return object

@codeCoverageIgnore