-
Notifications
You must be signed in to change notification settings - Fork 0
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
More Forms #8
Merged
More Forms #8
Conversation
This file contains 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
A new enumeration named FormTypes has been added under the namespace Renfordt\Larvatar\Enum. It currently includes three form types: Circle, Square, and Hexagon.
The main changes revolve around adding the option to generate either a circle or a square form for the avatar. This is accomplished by introducing a new FormTypes Enum and allowing the form type to be set and fetched. The generate function has been altered to adapt to these changes and to generate an SVG of the correct form based on the form type selected.
Updated the code to instantiate InitialsAvatar once in the constructor instead of multiple times in getImageHTML method of the Larvatar class. This optimizes the code by creating a single InitialsAvatar object simplifying calls to its methods and improving performance.
The InitialsAvatar class has been expanded to include a hexagonal form and a rotation property. A corresponding method getHexagon has also been implemented, which generates the coordinates of a hexagon based upon the size and rotation provided. Additionally, a new public method setRotation has been added to allow setting the rotation angle.
The comparison within the condition was adjusted to use the instance variable `$this->type` instead of the local variable `$type.` This change correctly reflects the Larvatar type and ensures that the appropriate InitialsAvatar object is created when the Larvatar type is set to `InitialsAvatar`.
A new function testGetHexagon is added to the InitialsAvatarTest class. This function tests if the getHexagon method of InitialsAvatar class is working correctly by asserting the return type, dimensions, fill color, and rotation of the resulting hexagon.
The changes in this commit eliminate the assertions checking the width and height of the SVGPolygon instance, as they are not necessary for the test. Instead, it has added an assertion to verify if the SVGPolygon's points retrieval method returns an empty array.
The changes remove a needless assertion checking for the SVG Polygon rotation in the InitialsAvatarTest. This assertion was not crucial for the test's purpose or for its passing, therefore it was removed to streamline the code.
The Hexagon tests within InitialsAvatarTest.php have been updated. An expected points array has been added to improve testing precision. Now, this test compares the generated points with a predefined set of expected points, improving the robustness of the testing for the Hexagon shape in InitialsAvatar.
Added new test methods to the InitialsAvatarTest to check for the correct setRotation and setForm behaviors. These methods aim at verifying the proper setting of rotation and form properties for an InitialsAvatar instance.
The FormTypes enum from the Larvatar package is now imported in the InitialsAvatarTest file. This change is crucial in setting up certain tests, specifically the testSetForm method that was also added in this commit.
The documentation for the avatar generation method has been updated to reflect the changes in functionality. The function now returns either a string or an SVG object. The comments have also been enhanced for clarity, specifically detailing that it generates an avatar based on provided names and encoding.
This change specifically revises the return type of the generate method in InitialsAvatar.php. The function is now guaranteed to only ever return a string, whether it's an SVG format avatar or a base64-encoded avatar image. This ensures more consistent return types for better predictability.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Instead of only having a circle for InitialsAvatar this pull request creates the possibilities for squares and also hexagons.