Set default configuration if none is provided

This commit is contained in:
Andrea Marco Sartori
2023-01-19 20:01:42 +10:00
parent 0e8130aabf
commit a3a63d36e8

View File

@ -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();
} }
/** /**