Skip to content

Conversation

@cjmellor
Copy link
Owner

@cjmellor cjmellor commented Sep 28, 2025

This pull request refines the logic for associating a new level with a user's experience in the levelUp method. The update ensures that the correct level model is retrieved and associated, and adds a safeguard for missing levels to be enforced in a future major version.

Level association logic improvement:

  • The method now retrieves the appropriate level model using the configured class and only associates it if the level exists, preventing potential errors from invalid level values.

Future strictness and error handling:

  • A TODO comment has been added to enforce strict behavior in the next major version by throwing an exception when a requested level does not exist, improving robustness and developer feedback.

Fixed #105

Summary by CodeRabbit

  • New Features

    • None.
  • Bug Fixes

    • Improved reliability of the levelling-up process by validating the target level before updating status. If the target level does not exist, the update is skipped to avoid incorrect associations.
    • Event notifications for levelling remain unchanged and continue to be emitted for each level in the range.
  • Chores

    • Internal safeguards added to prepare for stricter validation in a future major release.

@cjmellor cjmellor self-assigned this Sep 28, 2025
@cjmellor cjmellor added the bug Something isn't working label Sep 28, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ef4a58 and 81e7a58.

📒 Files selected for processing (1)
  • src/Concerns/GiveExperience.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Concerns/GiveExperience.php (1)
src/Models/Experience.php (1)
  • status (26-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PHP: v8.4 [prefer-stable]

@cjmellor cjmellor merged commit 26dbca6 into main Sep 28, 2025
8 of 25 checks passed
@cjmellor cjmellor deleted the 105-bug-levelup-function-associates-with-level-number-instead-of-level-id branch September 28, 2025 19:58
Repository owner deleted a comment from coderabbitai bot Sep 28, 2025
Repository owner deleted a comment from coderabbitai bot Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: levelUp() function associates with level number instead of level ID

1 participant