tractorcow / classproxy
Installs: 419 894
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- phpspec/prophecy: ^1.7
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-10-26 05:08:11 UTC
README
Dynamically scaffold proxy classes that actually extend the class being proxied, allowing them to be used in type-strict applications.
No it's not prophecy because this is designed for partial proxies, not testing.
Installation
composer require tractorcow/classproxy
Examples
// Create a proxy creator $proxy = ProxyFactory::create(DataBase::class) ->addMethod('connect', function ($args, $next) use ($logger) { $logger->log("Connecting to server " . $args[0]['server']; return $next(...$args); }); // Generate instance of our proxy $instance = $proxy->instance(); assert($instance instanceof Database); // Yep! // Connects to underlying database, logging the call $instance->connect([ 'server' => 'localhost', 'user' => 'root' ]);