-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
); | ||
} | ||
} |