Skip to content

Commit

Permalink
Change variadic to iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
jenky committed Jun 19, 2023
1 parent 0339cb8 commit 657b738
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/Decoder/ChainDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
final class ChainDecoder implements DecoderInterface
{
/**
* @var DecoderInterface[]
* @var iterable<DecoderInterface>
*/
private $decoders;

public function __construct(DecoderInterface ...$decoders)
/**
* @param iterable<DecoderInterface> $decoders
*/
public function __construct(iterable $decoders)
{
$this->decoders = $decoders;
}
Expand Down
12 changes: 8 additions & 4 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,13 @@ public function body(): PayloadInterface
*/
public function decoder(): DecoderInterface
{
return new ChainDecoder(
new JsonDecoder(),
new XmlDecoder()
);
$decoders = function () {
yield from [
new JsonDecoder(),
new XmlDecoder(),
];
};

return new ChainDecoder($decoders());
}
}

0 comments on commit 657b738

Please sign in to comment.