-
Notifications
You must be signed in to change notification settings - Fork 1
feat: improve API with newInstance method and optional FileUploadFactory #7
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a22e995
feat: improve API with newInstance method and optional FileUploadFactory
koriym 584b64d
fix: resolve static analysis errors for FileUploadFactory null checks
koriym d32ed14
feat: make file upload functionality optional with NullUploadFactory
koriym 21aede2
fix: restore FileUploadFactory in InputQueryTest for file upload tests
koriym a36e0f6
fix: add AbstractFileUpload to composer-require-checker whitelist
koriym 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\InputQuery\Demo; | ||
|
|
||
| /** | ||
| * Age Grouping Service - Stateful Singleton Service | ||
| * | ||
| * Key Learning Points: | ||
| * 1. Services can be injected into Input objects | ||
| * 2. Singleton services maintain state across multiple Input object creations | ||
| * 3. Business logic is separated from Input objects (Single Responsibility) | ||
| * 4. Input objects can collaborate with services during construction | ||
| * 5. Services accumulate knowledge as Input objects are created | ||
| */ | ||
| final class AgeGroup | ||
| { | ||
| /** @var array<string, int> */ | ||
| private array $groups = [ | ||
| 'under_25' => 0, | ||
| '25_35' => 0, | ||
| '36_50' => 0, | ||
| 'over_50' => 0, | ||
| ]; | ||
|
|
||
| public function addAge(?int $age): void | ||
| { | ||
| if ($age === null) { | ||
| return; | ||
| } | ||
|
|
||
| if ($age < 25) { | ||
| $this->groups['under_25']++; | ||
| } elseif ($age <= 35) { | ||
| $this->groups['25_35']++; | ||
| } elseif ($age <= 50) { | ||
| $this->groups['36_50']++; | ||
| } else { | ||
| $this->groups['over_50']++; | ||
| } | ||
| } | ||
|
|
||
| /** @return array<string, int> */ | ||
| public function getGroups(): array | ||
| { | ||
| return $this->groups; | ||
| } | ||
|
|
||
| public function getTotalCount(): int | ||
| { | ||
| return array_sum($this->groups); | ||
| } | ||
| } |
This file contains hidden or 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,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Ray\InputQuery\Demo; | ||
|
|
||
| use Ray\InputQuery\Attribute\Input; | ||
|
|
||
| /** | ||
| * Age Value Object with Domain Validation | ||
| * | ||
| * Key Learning Points: | ||
| * 1. Input objects can contain domain validation logic | ||
| * 2. Constructor validation ensures "creation = validity" principle | ||
| * 3. Ray.InputQuery automatically converts string to int before passing to constructor | ||
| * 4. If validation fails, object creation fails - no invalid objects exist | ||
| */ | ||
| final class AgeInput | ||
| { | ||
| public function __construct( | ||
| #[Input] public readonly int $age, // Ray.InputQuery converts CSV string "28" to int 28 | ||
| ){ | ||
| // Domain validation: Age must be non-negative | ||
| // This demonstrates the "creation = validity" principle | ||
| if ($age < 0) { | ||
| throw new \InvalidArgumentException('Age must be a non-negative integer.'); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.