Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 21 additions & 0 deletions src/Coder/NoCoder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace PetrKnap\Binary\Coder;

/**
* Special implementation of {@see CoderInterface} which does not code
*/
final class NoCoder implements CoderInterface
{
public function encode(string $decoded): string
{
return $decoded;
}

public function decode(string $encoded): string
{
return $encoded;
}
}
31 changes: 31 additions & 0 deletions tests/Coder/NoCoderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);

namespace PetrKnap\Binary\Coder;

use PHPUnit\Framework\Attributes\DataProvider;

final class NoCoderTest extends CoderTestCase
{
public static function data(): array
{
return [[self::getDecodedData()]];
}

#[DataProvider('data')]
public function testEncodes(string $data): void
{
self::assertSame(
$data,
(new NoCoder())->encode($data),
);
}

#[DataProvider('data')]
public function testDecodes(string $data): void
{
self::assertSame(
$data,
(new NoCoder())->decode($data),
);
}
}