PHP Classes

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    
Ratings Unique User Downloads Download Rankings
StarStarStar 56%Total: 1,172 This week: 1All time: 3,229 This week: 571Up
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: 42
All time rank: 885 in Brazil Brazil
Week rank: 420 Down38 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,172
This week:1
All time:3,229
This week:571Up
User Ratings User Comments (1)
 All time
Utility:81%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:56%StarStarStar
Rank:1799
 
Excellent
14 years ago (kishore kumar)
70%StarStarStarStar