-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert configuration to Value Object #284
Conversation
Yeah, that looks about right. Once we bump to PHP 8, we will even be able to switch to named parameters and ditch options resolver altogether. And then with |
Mostly to enforce type of each parameter of a config. Also, enforce type for the input configuration using `setAllowedTypes`.
Remove public method `getConfig` (which was only used internally)
789d220
to
84a3cec
Compare
I think I'm done @jtojnar, can you take a look? 🙏 |
* @param array $config | ||
*/ | ||
public function __construct($config = [], LoggerInterface $logger = null) | ||
public function __construct(array $config = [], LoggerInterface $logger = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could even require the objects instead of arrays to be passed to constructors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it could allow to better check for sub-configuration but I found it more verbose. You'll have to use object config for each level. I think it'll add complexity where array is really simple to use.
private array $http_client; | ||
private array $extractor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we might have objects here.
Mostly to enforce type of each parameter of a config.
Also, enforce type for the input configuration using
setAllowedTypes
.See #283 (review)
Is it something like that you were talking about @jtojnar?