Skip to content

Commit 7ca302c

Browse files
authored
Merge pull request #7 from petrknap/no-coder
Implemented "no coder" coder
2 parents 8a3e38d + bbc7db5 commit 7ca302c

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/Coder/NoCoder.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PetrKnap\Binary\Coder;
6+
7+
/**
8+
* Special implementation of {@see CoderInterface} which does not code
9+
*/
10+
final class NoCoder implements CoderInterface
11+
{
12+
public function encode(string $decoded): string
13+
{
14+
return $decoded;
15+
}
16+
17+
public function decode(string $encoded): string
18+
{
19+
return $encoded;
20+
}
21+
}

tests/Coder/NoCoderTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PetrKnap\Binary\Coder;
4+
5+
use PHPUnit\Framework\Attributes\DataProvider;
6+
7+
final class NoCoderTest extends CoderTestCase
8+
{
9+
public static function data(): array
10+
{
11+
return [[self::getDecodedData()]];
12+
}
13+
14+
#[DataProvider('data')]
15+
public function testEncodes(string $data): void
16+
{
17+
self::assertSame(
18+
$data,
19+
(new NoCoder())->encode($data),
20+
);
21+
}
22+
23+
#[DataProvider('data')]
24+
public function testDecodes(string $data): void
25+
{
26+
self::assertSame(
27+
$data,
28+
(new NoCoder())->decode($data),
29+
);
30+
}
31+
}

0 commit comments

Comments
 (0)