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

[Refact] configuration class #283

Merged

Conversation

@Jibbarth
Copy link
Collaborator

Jibbarth commented Oct 6, 2019

Q A
Bug fix? no
New feature? yes
Fixed tickets #...

In order to fix this comment, I add a Configuration Class that carry config provided by user.

The Configuration class is resolved when container boot, so we can use DependencyInjection or container to retrieve configuration.
So we don't have anymore the need to manually pass config everywhere we need it.

As phpcsfixer came with it, I use symfony/options-resolver to improve configuration validation.

I think this refact is needed, because the config file is growing, and we should have a simpler way to validate it, and also retrieve it.

WDYT ?

@Jibbarth Jibbarth added the enhancement label Oct 6, 2019
@nunomaduro nunomaduro requested a review from olivernybroe Oct 6, 2019
Copy link
Collaborator

olivernybroe left a comment

Wauw, this is really clean, I love it ❤️

I think this will allow us to do a lot of extra stuff soo much easier in the future.

I only had a few comments about some naming, but else it just looks spot on

src/Application/DirectoryResolver.php Show resolved Hide resolved
src/Domain/Configuration.php Outdated Show resolved Hide resolved
src/Domain/Configuration.php Outdated Show resolved Hide resolved
Jibbarth added 3 commits Oct 6, 2019
Resolve configuration when loading container
Use dependency injection for configuration
@Jibbarth Jibbarth force-pushed the Jibbarth:feature/configuration-class branch from 666e5f1 to e6a37e6 Oct 7, 2019
@Jibbarth

This comment has been minimized.

Copy link
Collaborator Author

Jibbarth commented Oct 7, 2019

@olivernybroe Do you think you could test it in a Laravel application before merging ?

To be sure the php artisan insights still works, especially when we pass a directory argument ?

@olivernybroe

This comment has been minimized.

Copy link
Collaborator

olivernybroe commented Oct 7, 2019

@Jibbarth Did not work in Laravel, gave the following error

 Illuminate\Contracts\Container\BindingResolutionException  : Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class NunoMaduro\PhpInsights\Domain\Configuration
@Jibbarth Jibbarth force-pushed the Jibbarth:feature/configuration-class branch from cc761f4 to 1b7846d Oct 7, 2019
@Jibbarth

This comment has been minimized.

Copy link
Collaborator Author

Jibbarth commented Oct 7, 2019

@olivernybroe I think it's fixed now. Can you check the last commit and tell me if it looks correct for you ?

😅 I made my first Laravel install to fix this 🙌

@olivernybroe

This comment has been minimized.

Copy link
Collaborator

olivernybroe commented Oct 8, 2019

@Jibbarth

It works, nicely done! 😄

Congratz on Laravel, now you gotta use it all the time ;)

But, thanks for the refactor! ❤️

@olivernybroe olivernybroe merged commit 8a60fbc into nunomaduro:master Oct 8, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@nunomaduro

This comment has been minimized.

Copy link
Owner

nunomaduro commented Oct 8, 2019

Thanks @Jibbarth for your work on this.

@Jibbarth Jibbarth deleted the Jibbarth:feature/configuration-class branch Oct 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.