diff --git a/src/Coder.php b/src/Coder.php index 0e21b97..a161570 100644 --- a/src/Coder.php +++ b/src/Coder.php @@ -4,11 +4,16 @@ namespace PetrKnap\Binary; +use Stringable; + /** * @internal shared logic */ -abstract class Coder +abstract class Coder implements Stringable { + /** + * @param string $data may contain binary data + */ final public function __construct( public readonly string $data = '', ) { @@ -20,7 +25,7 @@ final public function withData(string $data): static } /** - * @deprecated use readonly property $data + * @deprecated use readonly property {@see self::$data} */ final public function getData(): string { @@ -61,4 +66,12 @@ abstract public function xz(): static; * @throws Coder\Exception\CoderException */ abstract public function zlib(): static; + + /** + * @note this is just a helper, this class is not supposed to implement {@see BinariableInterface} + */ + public function __toString(): string + { + return $this->data; + } }