2017 © Pedro Peláez
 

library phroxy

Proxy generator that supports interception of method calls

image

tmont/phroxy

Proxy generator that supports interception of method calls

  • Wednesday, January 22, 2014
  • by tmont
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Phroxy

Build Status, (*1)

Phroxy is a proxy generator. It's probably useful. You can use it to create a mock object, or to create a proxy and intercept methods on that proxy., (*2)

Installation

User composer:, (*3)

{
  "require": {
    "tmont/phroxy": "1.1.x"
  }
}

Usage

I don't feel like writing documentation, so take a look at the unit tests. There are examples of basic proxying as well as advanced method interception., (*4)

The basic gist is:, (*5)

use Tmont\Phroxy\Interceptor;
use Tmont\Phroxy\InterceptorCache;
use Tmont\Phroxy\InterceptionContext;
use ReflectionClass;

class ReturnBeforeCallInterceptor implements Interceptor {
    public function onBeforeMethodCall(InterceptionContext $context) {
        $context->setReturnValue('oh hai!');
    }

    public function onAfterMethodCall(InterceptionContext $context) {}
}

class MyClass {
    public function hello() {
        return 'hello';
    }
}

$interceptor = new ReturnBeforeCallInterceptor();
InterceptorCache::registerInterceptor($interceptor, function($x) { return true; });

$proxy = $this->builder->build(new ReflectionClass('MyClass'));
$proxy->hello(); // "oh hai!"

Development

git clone git@github.com:tmont/phroxy.git
cd phroxy
composer install
vendor/bin/phpunit

The Versions

22/01 2014

dev-master

9999999-dev

Proxy generator that supports interception of method calls

  Sources   Download

WTFPL

The Development Requires

proxy interception intercept

22/01 2014

1.1.0

1.1.0.0

Proxy generator that supports interception of method calls

  Sources   Download

WTFPL

The Development Requires

proxy interception intercept