denshade/object_method_listener

There is no license information available for the latest version (dev-master) of this package.

A object method decorator

dev-master 2014-08-30 05:26 UTC

This package is not auto-updated.

Last update: 2024-10-08 08:08:21 UTC


README

What is it?

This is an implementation of a method listener in php. This allows for extending the behaviour of your classes without having them extend specific classes.

Classic composition is used to wrap the object, all method calls are caught so you can extend the behaviour none the less.

Features contain:

  • Make any object ReadOnly, making all setters throw UnsupportedExceptions.
  • Generate stack traces for every method call and log it to a log file.
  • ...

How it works

Simply wrap your object like so:

This will trace the observed object. If you interested in recording all of the accessors of a method(s).

$object = ObjectMutation::wrapAsTraceObserver($object, $outFile);

This will make the observed object readOnly.

$object = ObjectMutation::wrapAsReadonlyObject($object);

You can also make your own implementations of method listeners.