mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-07-09 16:26:32 +02:00
Set default configuration if none is provided
This commit is contained in:
@ -13,6 +13,13 @@ use Traversable;
|
|||||||
*/
|
*/
|
||||||
abstract class Source implements IteratorAggregate
|
abstract class Source implements IteratorAggregate
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The configuration.
|
||||||
|
*
|
||||||
|
* @var Config
|
||||||
|
*/
|
||||||
|
protected Config $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cached size of the JSON source.
|
* The cached size of the JSON source.
|
||||||
*
|
*
|
||||||
@ -47,9 +54,9 @@ abstract class Source implements IteratorAggregate
|
|||||||
* @param mixed $source
|
* @param mixed $source
|
||||||
* @param Config|null $config
|
* @param Config|null $config
|
||||||
*/
|
*/
|
||||||
final public function __construct(protected mixed $source, protected Config $config = null)
|
final public function __construct(protected mixed $source, Config $config = null)
|
||||||
{
|
{
|
||||||
$this->config ??= new Config();
|
$this->config = $config ?: new Config();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user