forked from Respect/Stringifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayObjectHandler.php
More file actions
39 lines (31 loc) · 891 Bytes
/
ArrayObjectHandler.php
File metadata and controls
39 lines (31 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* 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,
);
}
}