Skip to content

Commit cd99a46

Browse files
authored
Merge pull request #20 from petrknap/stringable-coder
`Coder` implements `Stringable`
2 parents 1d23cd5 + 51b9607 commit cd99a46

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Coder.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44

55
namespace PetrKnap\Binary;
66

7+
use Stringable;
8+
79
/**
810
* @internal shared logic
911
*/
10-
abstract class Coder
12+
abstract class Coder implements Stringable
1113
{
14+
/**
15+
* @param string $data may contain binary data
16+
*/
1217
final public function __construct(
1318
public readonly string $data = '',
1419
) {
@@ -20,7 +25,7 @@ final public function withData(string $data): static
2025
}
2126

2227
/**
23-
* @deprecated use readonly property $data
28+
* @deprecated use readonly property {@see self::$data}
2429
*/
2530
final public function getData(): string
2631
{
@@ -61,4 +66,12 @@ abstract public function xz(): static;
6166
* @throws Coder\Exception\CoderException
6267
*/
6368
abstract public function zlib(): static;
69+
70+
/**
71+
* @note this is just a helper, this class is not supposed to implement {@see BinariableInterface}
72+
*/
73+
public function __toString(): string
74+
{
75+
return $this->data;
76+
}
6477
}

0 commit comments

Comments
 (0)