talesoft / tale-factory
A generic factory implementation
Installs: 35 409
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
Requires (Dev)
- talesoft/tale-dev-tool: ^0.2.5
This package is auto-updated.
Last update: 2024-10-21 20:17:25 UTC
README
What is Tale Factory?
A generic implementation of the factory pattern.
Installation
composer require talesoft/tale-factory
Usage
use Tale\Factory; interface AdapterInterface { public function sayHello(): void; } class TestAdapter { private $message; public function __construct(string $message) { $this->message = $message; } public function sayHello(): void { echo $this->message; } } $factory = new Factory( AdapterInterface::class, ['Hello from adapter!'], [ 'test' => TestAdapter::class ] ); $instance = $factory->get('test'); $instance->sayHello(); //"Hello from adapter!"
TODO: More docs.