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

Make Check macroable and allow chaining callables in if() and unless() #184

Merged
merged 8 commits into from
Jul 21, 2023
Merged

Make Check macroable and allow chaining callables in if() and unless() #184

merged 8 commits into from
Jul 21, 2023

Conversation

oprypkhantc
Copy link
Contributor

@oprypkhantc oprypkhantc commented Jul 6, 2023

This would allow adding custom health checks filtering using macros:

Check::macro('inProduction', function () {
    return $this->if(fn () => app()->isProduction());
});

Check::macro('inContainerTypes', function (array $types) {
    return $this->if(fn () => in_array(app()->containerType(), $types));
});

Health::checks([
    DebugCheck::new()
        ->inProduction()
        ->inContainerTypes(['app']),
]);

@oprypkhantc oprypkhantc changed the title Make Check macroable and allow callables in if() and unless() Make Check macroable and allow chaining callables in if() and unless() Jul 10, 2023
@freekmurze
Copy link
Member

Looks neat! Could you also write documentation for this?

@freekmurze
Copy link
Member

Seems like the tests are also failing, could you take a look at that?

@oprypkhantc
Copy link
Contributor Author

Sure thing :) I've fixed the tests and added documentation. I added a new .md docs page; it should appear in the docs by itself or do I need to add the page somewhere?

@freekmurze freekmurze merged commit 2e5ea91 into spatie:main Jul 21, 2023
@freekmurze
Copy link
Member

Thank you!

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.

2 participants