Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Coder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '',
) {
Expand All @@ -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
{
Expand Down Expand Up @@ -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;
}
}
Loading