2017 © Pedro Peláez
 

library odango

AOP inspired advice/function compositor

image

lapaz/odango

AOP inspired advice/function compositor

  • Monday, May 29, 2017
  • by tanakahisateru
  • Repository
  • 2 Watchers
  • 1 Stars
  • 77 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Odango

Build Status, (*1)

Odango is a function compositor inspired by Aspect Oriented Programming (AOP)., (*2)

To separate concerns is better practice even if you don't know AOP, for example caching, logging, transaction, security filter, event dispatching or such as. Cross cutting concerns should be separated from your business logic., (*3)

This is not an AOP weaving framework. I prefer Ray.Aop instead if you want some full featured AOP like a Google Guice or such as., (*4)

Example

$withLoggedTransaction = AdviceComposite::of(
    function ($invocation) use ($logger) {
        $logger->info('Starting transaction.');
        $result = $invocation->proceed();
        $logger->info('Transaction comitted.');
        return $result;
    }
)->with(
    function ($invocation) use ($db) {
        $db->beginTransaction();
        try {
            $result = $invocation->proceed();
            $db->commit();
            return $result;
        } catch (\Exception $ex) {
            $dbh->rollBack();
            throw $ex;
        }
    }
);

$storeDataInvocation = [$this, 'storeData']; // Some callable
$storeDataInvocation = $withLoggedTransaction->bind($storeDataInvocation);

$storeDataInvocation($data);

Odango supports Ray.Aop's MethodInterceptor as composition target. So, existing AOP assets may be reusable., (*5)

Remark that AdviceComposite instance is immutable because generated function references the creation context. Modification breaks it., (*6)

Known issue

Joinpoint::getThis() and Joinpoint::getMethod() are throw a BadMethodCallException because no object context are bounded., (*7)

The Versions

29/05 2017

dev-master

9999999-dev

AOP inspired advice/function compositor

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2017

0.1.0

0.1.0.0

AOP inspired advice/function compositor

  Sources   Download

MIT

The Requires

 

The Development Requires