-
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e497999
Update client specifications
RikudouSage dde9f27
Make tests work again
RikudouSage ce69054
Add global segments handling
RikudouSage 43d05ed
Add tests that are triggered to complete coverage
RikudouSage 0417e90
Pass header with spec version
RikudouSage 1b38aa1
Pass header with spec version
RikudouSage b347622
Don't unpack array multiple times
RikudouSage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO; | ||
|
||
final class DefaultSegment implements Segment | ||
{ | ||
/** | ||
* @param array<Constraint> $constraints | ||
*/ | ||
public function __construct( | ||
private readonly int $id, | ||
private readonly array $constraints, | ||
) { | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getConstraints(): array | ||
{ | ||
return $this->constraints; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO; | ||
|
||
interface Segment | ||
{ | ||
public function getId(): int; | ||
|
||
/** | ||
* @return array<Constraint> | ||
*/ | ||
public function getConstraints(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Unleash\Client\DTO\DefaultSegment; | ||
|
||
/** | ||
* 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 commentThe reason will be displayed to describe this comment to others. Learn more. Nice, that's pretty clever! |
||
*/ | ||
final class CoverageOnlyTest extends TestCase | ||
{ | ||
public function testDefaultSegment(): void | ||
{ | ||
$instance = new DefaultSegment(1, []); | ||
self::assertEquals(1, $instance->getId()); | ||
} | ||
} |
Submodule client-specification
updated
12 files
+1 −0 | .github/stale.yml | |
+14 −0 | .github/workflows/add-to-project.yml | |
+2 −2 | .github/workflows/node.js.yml | |
+29 −0 | .github/workflows/release.yml | |
+4 −3 | README.md | |
+1 −0 | index.js | |
+2 −2 | package.json | |
+1 −1 | schema/context-schema.js | |
+16 −0 | schema/features-schema.js | |
+68 −0 | specifications/13-constraint-operators.json | |
+201 −0 | specifications/15-global-constraints.json | |
+3 −2 | specifications/index.json |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!