Skip to content

Enhance Attribute and Property Handling for Parts #1320

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

valzargaming
Copy link
Member

@valzargaming valzargaming commented Apr 15, 2025

This is merely meant as a proof of concept at this time.

Summary

This PR introduces enhancements to the PartTrait class by adding new methods to improve attribute and property handling. These changes aim to provide better flexibility and maintainability when working with part attributes and properties.

Changes Introduced

  1. New Methods Added:

    • checkForGetMethod: Checks if a get method exists for a given key.
    • checkForSetMethod: Checks if a set method exists for a given key.
    • getProperty: Retrieves a property using a get method if it exists.
    • setAttributeOrProperty: Sets an attribute or a property, supporting mutators and methods.
  2. Enhancements to Magic Methods:

    • Updated __get to use getProperty as a fallback if the attribute does not exist.
    • Updated __set to utilize setAttributeOrProperty for setting values.
  3. Improved Code Maintainability:

    • Consolidated logic for handling attributes and properties in a consistent and reusable manner.

Example Usage

$part->discord; // Will attempt to use getDiscord() if it exists
$part->color = (0xE1452D); // Will attempt to use setColor() if it exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant