BenMakesGames/PoppySeedPets
update entity properties, getters, and setters to be strongly typed; use __construct to ensure entities are newed up in a valid state
Open
#34 opened on Apr 14, 2025
good first issuetech debt
Repository metrics
- Stars
- (14 stars)
- PR merge metrics
- (PR metrics pending)
Description
context: the make:entity is pretty good for creating and updating entities, but it allows many properties to be null, even if they shouldn't be. this can lead to bugs.
to reduce the chance of bugs, aim for objects to always be in a valid state.
todo:
- update entity properties, and related getter and setter, to be strongly-typed (including accounting for nullability)
- ensure entities are always newed up in a valid state; possibilities:
- add required properties to
__construct- easy, works best when required properties are low- this option will probably cover the majority of cases
- make
__constructprivate and create static factory methods - similar to above; preferable when there are multiple ways to construct an entity - create a builder class (preferably with a fluent API) that assists with creating the entity - appropriate only when newing up an entity is very complex
- add required properties to
it's totally legit to upgrade just one entity or a small group of entities in a PR; this issue will be closed when all entities are updated.