Skip to content

Decorate the contract

Decorate the contract

Because callers depend on Contracts\Operations, you can bind a decorator that adds logging, metrics, or authorization without touching call sites:

$this->app->extend(Operations::class, function (Operations $inner, $app) {
    return new LoggingOperations($inner, $app['log']);
});

Your decorator implements Operations, forwards to $inner, and adds its own concern around each call.