Skip to content

Commit

Permalink
Merge pull request #7 from petrknap/no-coder
Browse files Browse the repository at this point in the history
Implemented "no coder" coder
  • Loading branch information
petrknap committed Apr 3, 2024
2 parents 8a3e38d + bbc7db5 commit 7ca302c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
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),
);
}
}

0 comments on commit 7ca302c

Please sign in to comment.