* SPDX-License-Identifier: MIT */ declare(strict_types=1); namespace Respect\Stringifier\Handlers; use ArrayObject; use Respect\Stringifier\Handler; use Respect\Stringifier\Helpers\ObjectHelper; use Respect\Stringifier\Quoter; final class ArrayObjectHandler implements Handler { use ObjectHelper; public function __construct( private readonly Handler $handler, private readonly Quoter $quoter, ) { } public function handle(mixed $raw, int $depth): string|null { if (!$raw instanceof ArrayObject) { return null; } return $this->quoter->quote( $this->format($raw, 'getArrayCopy() =>', $this->handler->handle($raw->getArrayCopy(), $depth + 1)), $depth, ); } }