-
Notifications
You must be signed in to change notification settings - Fork 14
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
Feat: Global segments #104
Conversation
$constraints = $strategy->getConstraints(); | ||
$segments = method_exists($strategy, 'getSegments') ? $strategy->getSegments() : []; | ||
foreach ($segments as $segment) { | ||
$constraints = [...$constraints, ...$segment->getConstraints()]; |
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.
This looks to my very uninformed PHP eyes that this is unpacking each segment into the array in a loop. Is this an efficient way to do this? I'm mostly asking because we have folks that are wanting to use this feature to create very large segments and reuse them a lot
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.
You're right, that could be a little inefficient, don't know what I was thinking. I redid it to use yield and also got rid of one null check that wasn't necessary in each iteration.
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.
Hahaha, this is why we do code review, I do things like this all the time :)
Thank you! That looks great!
|
||
/** | ||
* This class is only for triggering code that doesn't really make sense to test and is here to achieve 100% code coverage. | ||
* The reason is to catch potential problems during transpilation to lower versions of php. |
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.
Nice, that's pretty clever!
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.
This looks great I see all the spec test are passing, the code looks really nice, I'm happy to merge if you're happy here
Yep, good to go, thanks! |
Description
Global segments
Fixes #103
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: