Refine decoders

This commit is contained in:
Andrea Marco Sartori 2023-01-19 19:16:02 +10:00
parent d8f494172c
commit 61f2102302
3 changed files with 9 additions and 6 deletions

View File

@ -15,6 +15,7 @@ abstract class AbstractDecoder implements Decoder
*
* @param string $json
* @return mixed
* @throws Throwable
*/
abstract protected function decodeJson(string $json): mixed;

View File

@ -3,17 +3,17 @@
namespace Cerbero\JsonParser\Decoders;
/**
* The decoder using the default JSON decoder.
* The decoder using the built-in JSON decoder.
*
*/
class JsonDecoder extends AbstractDecoder
final class JsonDecoder extends AbstractDecoder
{
/**
* Instantiate the class.
*
* @param bool $decodesToArray
*/
public function __construct(protected bool $decodesToArray = true)
public function __construct(private bool $decodesToArray = true)
{
}
@ -22,6 +22,7 @@ class JsonDecoder extends AbstractDecoder
*
* @param string $json
* @return mixed
* @throws \Throwable
*/
protected function decodeJson(string $json): mixed
{

View File

@ -3,17 +3,17 @@
namespace Cerbero\JsonParser\Decoders;
/**
* The simdjson decoder.
* The decoder using the simdjson library.
*
*/
class SimdjsonDecoder extends AbstractDecoder
final class SimdjsonDecoder extends AbstractDecoder
{
/**
* Instantiate the class.
*
* @param bool $decodesToArray
*/
public function __construct(protected bool $decodesToArray = true)
public function __construct(private bool $decodesToArray = true)
{
}
@ -22,6 +22,7 @@ class SimdjsonDecoder extends AbstractDecoder
*
* @param string $json
* @return mixed
* @throws \Throwable
*/
protected function decodeJson(string $json): mixed
{