-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
91366ea
commit 0d88c71
Showing
22 changed files
with
168 additions
and
297 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
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
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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Facile\PhpCodec; | ||
|
||
use Facile\PhpCodec\Validation\Context; | ||
use Facile\PhpCodec\Validation\Validation; | ||
|
||
/** | ||
* @template A | ||
* @template I | ||
* @template O | ||
* | ||
* @implements Codec<A, I, O> | ||
*/ | ||
class ConcreteCodec implements Codec | ||
{ | ||
/** @var Decoder<I, A> */ | ||
private $decoder; | ||
/** @var Encoder<A, O> */ | ||
private $encoder; | ||
|
||
/** | ||
* @param Decoder<I, A> $decoder | ||
* @param Encoder<A, O> $encoder | ||
*/ | ||
public function __construct(Decoder $decoder, Encoder $encoder) | ||
{ | ||
$this->decoder = $decoder; | ||
$this->encoder = $encoder; | ||
} | ||
|
||
public function validate($i, Context $context): Validation | ||
{ | ||
return $this->decoder->validate($i, $context); | ||
} | ||
|
||
public function decode($i): Validation | ||
{ | ||
return $this->decoder->decode($i); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->decoder->getName(); | ||
} | ||
|
||
public function encode($a) | ||
{ | ||
return $this->encoder->encode($a); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.