runByName() public static method

Everything is possible with AOP, so static methods can be intercepted too
public static runByName ( string $task )
$task string Some specific argument
Beispiel #1
0
 case 'cacheable':
     $aspectName = 'Demo\\Aspect\\CachingAspect';
     $example = new CacheableDemo();
     $result = $example->getReport(12345);
     // First call will take 0.1 second
     echo "Result is: ", $result, PHP_EOL;
     $result = $example->getReport(12346);
     // This call is cached and result should be '12345'
     echo "Result is: ", $result, PHP_EOL;
     break;
 case 'loggable':
     $aspectName = 'Demo\\Aspect\\LoggingAspect';
     $example = new LoggingDemo();
     $example->execute('LoggingTask');
     // Logging for dynamic methods
     LoggingDemo::runByName('StaticTask');
     // Logging for static methods
     break;
 case 'property-interceptor':
     $aspectName = 'Demo\\Aspect\\PropertyInterceptorAspect';
     $example = new PropertyDemo();
     echo $example->publicProperty;
     // Read public property
     $example->publicProperty = 987;
     // Write public property
     $example->showProtected();
     $example->setProtected(987);
     break;
 case 'dynamic-interceptor':
     $aspectName = 'Demo\\Aspect\\DynamicMethodsAspect';
     $example = new DynamicMethodsDemo();