Skip to content
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

Merged
merged 7 commits into from
Feb 2, 2022
Merged

Conversation

j0k3r
Copy link
Owner

@j0k3r j0k3r commented Jan 24, 2022

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?

@coveralls
Copy link

coveralls commented Jan 24, 2022

Coverage Status

Coverage increased (+0.03%) to 95.035% when pulling bb954af on feature/config-as-value-object into 68aa280 on master.

@jtojnar
Copy link
Collaborator

jtojnar commented Jan 24, 2022

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 readonly properties, we won’t even need the getters.

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)
@j0k3r j0k3r force-pushed the feature/config-as-value-object branch from 789d220 to 84a3cec Compare January 27, 2022 12:42
@j0k3r j0k3r marked this pull request as ready for review January 27, 2022 13:37
@j0k3r
Copy link
Owner Author

j0k3r commented Jan 27, 2022

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)
Copy link
Collaborator

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.

Copy link
Owner Author

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.

Comment on lines +27 to +28
private array $http_client;
private array $extractor;
Copy link
Collaborator

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.

@j0k3r j0k3r added this to the 3.0.0 milestone Jan 31, 2022
@j0k3r j0k3r merged commit d395eeb into master Feb 2, 2022
@j0k3r j0k3r deleted the feature/config-as-value-object branch February 2, 2022 11:55
@j0k3r j0k3r mentioned this pull request Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants