Update UserFactory.php #64
Open
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.
An Overview of Updates for UserFactory
"Refactoring of User Factory, August, 2012".refactor>User Factory.
Overview of Refactoring of User Factory
The User Factory class is now more maintainable through several changes:
Changes to the User Factory
The new explicitly defined return types in the User Factory are 'array' and 'self', which provide IDEs and static analysis tools with better support. Named constants are created from 'hardcoded' configuration values like 'DEFAULT_PASSWORD', 'REMEMBER_TOKEN_LENGTH', and can be changed in one place instead of multiple times in the codebase. The 'unverified()' method has been simplified to avoid an unnecessary closure and returns the 'state' array directly instead. Verbose documentation blocks for the User Factory class have been removed and replaced with inline type declarations whenever possible. Whitespace and comments have been cleaned up and removed from the User Factory.
Benefits of User Factory Refactoring
Configuration value location is easier to find and/or modify, e.g., password length or token length. IDE autocompletion and static analysis are better supported. Fewer lines of code, but it is still clear.
Typed properties are available using PHP 7.4+ standards. It is faster to locate methods by constant reference instead of function reference. No functional changes have been made to the User Factory; it functions just as before, but is now more concise and easier to maintain.