PHPackages                             hartmann/resolve-strategy-interface - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hartmann/resolve-strategy-interface

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hartmann/resolve-strategy-interface
===================================

resolve-strategies allow you to resolve dependencies through a user-defined process

1.1.0(7y ago)0431MITPHPPHP &gt;=7.1

Since Apr 23Pushed 7y agoCompare

[ Source](https://github.com/mark-hartmann/resolve-strategy-interface)[ Packagist](https://packagist.org/packages/hartmann/resolve-strategy-interface)[ RSS](/packages/hartmann-resolve-strategy-interface/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

Resolve Strategy Interface
==========================

[](#resolve-strategy-interface)

A strategy allows you to resolve a dependency through a user-defined process.

For example, if there are multiple request classes (`CreateUserRequest`, `DeletePostRequest`, ...) that inherit from `Request` and are created in the same way
(for example using the `::createFromEnvironment` method), you can do the following with a ResolveStrategy:

```
use \Hartmann\ResolveStrategy\ResolveStrategyInterface

class ResolveRequestStrategy implements ResolveStrategyInterface
{
    /**
     * Checks wether the given class can be resolved by this strategy
     *
     * @param string $class The fully qualified namespace of the class to be resolved
     *
     * @return bool
     */
    public function suitable(string $class): bool
    {
        return method_exists($class, 'createFromEnvironment') && preg_match('/^.+?Request$/') === 1;
    }

    /**
     * A strategy allows you to resolve a dependency through a user-defined process.
     * For example, if a class is instantiated by a static method (e.g. ::createFromEnvironment), this can be resolved by a strategy.
     *
     * @param \Psr\Container\ContainerInterface $container The instance of the PSR-11 container
     * @param string                            $class     The fully qualified namespace of the class to be resolved
     *
     * @return object The instance of the requested class
     */
    public function resolve(\Psr\Container\ContainerInterface $container, string $class)
    {
        return call_user_func([$class, 'createFromEnvironment'], $container->get('environment'));
    }
}
```

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2625d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21173286?v=4)[Mark Hartmann](/maintainers/mark-hartmann)[@mark-hartmann](https://github.com/mark-hartmann)

---

Top Contributors

[![mark-hartmann](https://avatars.githubusercontent.com/u/21173286?v=4)](https://github.com/mark-hartmann "mark-hartmann (3 commits)")

### Embed Badge

![Health badge](/badges/hartmann-resolve-strategy-interface/health.svg)

```
[![Health](https://phpackages.com/badges/hartmann-resolve-strategy-interface/health.svg)](https://phpackages.com/packages/hartmann-resolve-strategy-interface)
```

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k447.1M9.1k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

706127.7M12.7k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31180.7M2.3k](/packages/illuminate-container)[symfony/type-info

Extracts PHP types information.

20062.9M225](/packages/symfony-type-info)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
