PHP Classes
elePHPant
Icontem

Access Methods: Map variable accesses to accessor method calls

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2006-07-19 (10 years ago) RSS 2.0 feedStarStarStarStar 63%Total: 1,166 All time: 3,129 This week: 1,016Up
Version License Categories
accessmethods 1.0BSD LicensePHP 5, Language
Description Author

This class can be used to map accesses to class variables into calls to setter and getter methods.

It provides functions that can called from a class __set and __get methods to automatically set or get the property values by calling the class setter and getter methods for the respective properties.

For example, if there is a property named "name", the class accessor methods usually are named of "getName" and "setName". Accesses to $object->name property are mapped to $object->setName($value) and $object->getName() calls.

Innovation Award
PHP Programming Innovation award nominee
July 2006
Number 7
Some authors prefer to encapsulate the access to the properties of objects of a class using setter and getter functions and making the property variables private.

This approach allows allows changing the implementation of the access to the properties without changing the interface of the class.

Despite the advantages of this approach, many users prefer the variable assignment syntax to set or get the property values, as it is less tedious.

This class makes possible to use the variable assignment syntax to access the properties while keeping the setter and getter approach.

It takes advantage of the PHP 5 special class functions __set and __get functions and the reflection API to determine which functions should be called set or get property values.

Manuel Lemos
Name: Olavo Alexandrino <contact>
Classes: 8 packages by
Country: Brazil Brazil
Age: 35
All time rank: 855 in Brazil Brazil
Week rank: 1181 Down91 in Brazil Brazil Down
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files  
File Role Description
Accessible without login Plain text file test.php Example An example of use
Plain text file class.AccessMethods.php Class The AccessMethods class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,166
This week:0
All time:3,129
This week:1,016Up
User Ratings User Comments (1)
 All time
Utility:91%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:63%StarStarStarStar
Rank:855
 
Excellent
7 years ago (kishore kumar)
70%StarStarStarStar