Skip to content

Commit 95887e3

Browse files
committed
Create Quoter and Stringifier
1 parent 6452c90 commit 95887e3

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/Quoter.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Respect/Stringifier.
5+
*
6+
* (c) Henrique Moody <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the "LICENSE.md"
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Respect\Stringifier;
15+
16+
interface Quoter
17+
{
18+
/**
19+
* Should add quotes to the given string.
20+
*
21+
* @param string $string The string to add quotes to
22+
* @param int $depth The current depth
23+
*
24+
* @return string
25+
*/
26+
public function quote(string $string, int $depth): string;
27+
}

src/Stringifier.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Respect/Stringifier.
5+
*
6+
* (c) Henrique Moody <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the "LICENSE.md"
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Respect\Stringifier;
15+
16+
interface Stringifier
17+
{
18+
/**
19+
* Converts the value into string if possible.
20+
*
21+
* @param mixed $raw The raw value to be converted.
22+
* @param int $depth The current depth of the conversion.
23+
*
24+
* @return null|string Returns NULL when the conversion is not possible.
25+
*/
26+
public function stringify($raw, int $depth): ?string;
27+
}

0 commit comments

Comments
 (0)