Access Methods: Map variable accesses to accessor method calls

Recommend this page to a friend!
  Info   View files (2)   Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
63%Total: 1,171 All time: 3,192 This week: 423
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
Picture of Olavo Alexandrino
Name: Olavo Alexandrino <contact>
Classes: 8 packages by
Country: Brazil Brazil
Age: 39
All time rank: 885 in Brazil Brazil
Week rank: 713 35 in Brazil Brazil
Innovation award
Innovation award
Nominee: 1x

  Files  
File Role Description
test.php Example An example of use
class.AccessMethods.php Class The AccessMethods class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,171
This week:0
All time:3,192
This week:423
User Ratings User Comments (1)
 All time
Utility:91%
Consistency:91%
Documentation:-
Examples:83%
Tests:-
Videos:-
Overall:63%
Rank:1000
 
Excellent
10 years ago (kishore kumar)
70%
 

For more information send a message to info at phpclasses dot org.