Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: factory #5

Open
GromNaN opened this issue Jul 5, 2022 · 0 comments
Open

Feature request: factory #5

GromNaN opened this issue Jul 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@GromNaN
Copy link
Collaborator

GromNaN commented Jul 5, 2022

The new ClassName is a hard dependency. In order to allow dependency injection, we can add a endeavor factory. This factory being stateless, it would be used in service declaration in Symfony container.

Once #4 is implemented, this will simplify the automatic injection of the logger.

Usage:

class MyService
{
    public function __construct(
        private EndeavorFactory $endeavor,
    ) {}

    public function process()
    {
        // random code
        $this->endeavor->constant(500)->run(function () {
            // Actual processing
        });
    }
}

Factory method would be:

interface EndeavorFactory
{
    // Create ConstantStrategy
    public function constant(/* ... */);

    // Create ExponentialStrategy
    public function exponential(/* ... */);

    // Create LinearStrategy
    public function linear(/* ... */);

    // Create MultiplicativeStrategy
    public function multiplicative(/* ... */);
}
@GromNaN GromNaN added the enhancement New feature or request label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant