forked from Respect/StringFormatter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestingModifier.php
More file actions
32 lines (23 loc) · 747 Bytes
/
TestingModifier.php
File metadata and controls
32 lines (23 loc) · 747 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
<?php
/*
* SPDX-FileCopyrightText: (c) Respect Project Contributors
* SPDX-License-Identifier: ISC
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
*/
declare(strict_types=1);
namespace Respect\StringFormatter\Test\Helper;
use Respect\StringFormatter\Modifier;
use function print_r;
use function sprintf;
final class TestingModifier implements Modifier
{
public string|null $lastPipe = null;
public function __construct(private string|null $customResult = null)
{
}
public function modify(mixed $value, string|null $pipe): string
{
$this->lastPipe = $pipe;
return $this->customResult ?? ($pipe ? sprintf('%s(%s)', $pipe, print_r($value, true)) : print_r($value, true));
}
}