Is there a reason the string has to be put into the constructor, and the actual config happens at runtime?
It makes it difficult for DI and libraries/config to adjust the object ones in constructing and then using it.
If you look into e.g.
https://commonmark.thephpleague.com/1.5/extensions/github-flavored-markdown/
or https://github.com/kzykhys/Ciconia/blob/master/src/Ciconia/Ciconia.php#L42
Then you usually make the builder itself stateless and instead wrap statefulness internally.
$env = .. // Can contain all the filters and stuff
$options = [
'xhtmlOutput' => true,
'strictMode' => false,
'escapeHtml' => true
];
// We can pass defaults here if we want
$instance = new Decoda($env, $options);
// We can also set options here per convertion
$html = $instance->convert($bbcodeText, $options);
$html2 = $instance->convert($bbcodeText2, $otherOptions);
What do you think?
There will also be no need for reset() then as it keeps the wrapper stateless and reuses the objects here.
Is there a reason the string has to be put into the constructor, and the actual config happens at runtime?
It makes it difficult for DI and libraries/config to adjust the object ones in constructing and then using it.
If you look into e.g.
https://commonmark.thephpleague.com/1.5/extensions/github-flavored-markdown/
or https://github.com/kzykhys/Ciconia/blob/master/src/Ciconia/Ciconia.php#L42
Then you usually make the builder itself stateless and instead wrap statefulness internally.
What do you think?
There will also be no need for reset() then as it keeps the wrapper stateless and reuses the objects here.