Skip to content

refactor: adopt eco library and restructure result handling#19

Merged
valb-mig merged 19 commits into
mainfrom
wip/result-and-error
Mar 18, 2026
Merged

refactor: adopt eco library and restructure result handling#19
valb-mig merged 19 commits into
mainfrom
wip/result-and-error

Conversation

@valb-mig
Copy link
Copy Markdown
Collaborator

Overview

This PR introduces eco as the foundation for result and error handling across the application, replacing the internal Result and Error utilities. Alongside the library adoption, the application layer was restructured to enforce a clear separation between validation (Input) and execution (UseCase).


Error handling

  • Removed src/Core/Utils/Result.php and src/Core/Utils/Error.php
  • All result and error handling now goes through eco's Result and Error classes

Input value objects

  • Introduced RollDiceInput and StartSessionInput as dedicated value objects
  • Validation is handled at construction time via eco's ensure() pipeline
  • Removed the old RollDiceUseCaseInput and StartSessionUseCaseInput

Use cases

  • Removed unnecessary try/catch blocks from RollDiceUseCase and StartSessionUseCase
  • UseCases now assume valid input — validation is the Input's responsibility
  • I/O classes renamed to drop the UseCase suffix (RollDiceOutput, StartSessionOutput)

Domain

  • Added DiceModifier value object with fromString() and apply()
  • Removed dead try/catch from RollDiceAction
  • Added StrHandler for string sanitization

Console

  • Removed console entry point commands, superseded by the new structure

Tests

  • 100% coverage on all new and modified classes
  • Added RollDiceActionTest, DiceModifierTest, RollDiceInputTest, StartSessionInputTest, StartSessionUseCaseTest

Breaking changes

  • eco is now a required dependency — run composer install after pulling
  • RollDiceUseCaseInput, StartSessionUseCaseInput and the internal Result/Error classes have been removed

@valb-mig valb-mig self-assigned this Mar 18, 2026
@valb-mig valb-mig added the refactor Refactoring label Mar 18, 2026
@valb-mig valb-mig merged commit c5cf5f6 into main Mar 18, 2026
4 checks passed
@valb-mig valb-mig deleted the wip/result-and-error branch March 18, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant