PHPackages                             ock/adaptism - 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. ock/adaptism

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

ock/adaptism
============

Library to map adapter classes.

1.x-dev(12mo ago)03311MITPHPPHP &gt;=8.3CI failing

Since Sep 14Pushed 11mo agoCompare

[ Source](https://github.com/ock-php/adaptism)[ Packagist](https://packagist.org/packages/ock/adaptism)[ Docs](https://github.com/ock/adaptism)[ RSS](/packages/ock-adaptism/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (87)Used By (1)

[![Build Status](https://camo.githubusercontent.com/731d910679eea269bd985b64040877b7edd6c3fd406d79118b4a14fd50edc8b6/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6f636b2f616461707469736d2e706e67)](https://travis-ci.org/ock/adaptism)[![Coverage Status](https://camo.githubusercontent.com/189118c86dab7bcb7f48f9689c2bc1dd14a2667de60f965dc5c8d2557523f306/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6f636b2f616461707469736d2f62616467652e706e67)](https://coveralls.io/r/ock/adaptism)

Adaptism
========

[](#adaptism)

Adaptism is a package that finds adapters for objects using a dispatch map.

Adapters can be annotated with [attributes](src/Attribute/Adapter.php) for discovery.

Convert objects
---------------

[](#convert-objects)

```
use Ock\Adaptism\Tests\Fixtures\Color\Hex\HexColorInterface;
use Ock\Adaptism\Tests\Fixtures\Color\Rgb\RgbColor;
use Ock\Adaptism\UniversalAdapter\UniversalAdapterInterface;

function f(UniversalAdapterInterface $universalAdapter): void {
  $rgb = new RgbColor(255, 0, 0);
  $hex = $universalAdapter->adapt($rgb, HexColorInterface::class);

  assert($hex instanceof HexColorInterface);
  assert($hex->getHexCode() === 'ff0000');
}
```

Declare adapters
----------------

[](#declare-adapters)

```
use Ock\Adaptism\Attribute\Adapter;
use Ock\Adaptism\Attribute\Parameter\Adaptee;
use Ock\Adaptism\Tests\Fixtures\Color\Hex\HexColorInterface;
use Ock\Adaptism\Tests\Fixtures\Color\Rgb\RgbColor;
use Ock\Adaptism\Tests\Fixtures\Color\Rgb\RgbColorInterface;

class C {
  #[Adapter]
  public static function adapt(
    #[Adaptee] RgbColorInterface $rgb,
  ): HexColorInterface {
    return new RgbColor(
      sprintf(
        '%02x%02x%02x',
        $rgbColor->red(), $rgbColor->green(), $rgbColor->blue()));
  }
}
```

More examples?
--------------

[](#more-examples)

Study [the tests](tests/src/AdapterTest.php)!

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance50

Moderate activity, may be stable

Popularity12

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

Unknown

Total

1

Last Release

360d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150032?v=4)[Andreas Hennings](/maintainers/donquixote)[@donquixote](https://github.com/donquixote)

---

Top Contributors

[![donquixote](https://avatars.githubusercontent.com/u/150032?v=4)](https://github.com/donquixote "donquixote (75 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ock-adaptism/health.svg)

```
[![Health](https://phpackages.com/badges/ock-adaptism/health.svg)](https://phpackages.com/packages/ock-adaptism)
```

###  Alternatives

[civicrm/civicrm-core

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

728272.9k20](/packages/civicrm-civicrm-core)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[symfony/ux-cropperjs

Cropper.js integration for Symfony

19280.3k3](/packages/symfony-ux-cropperjs)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)[indragunawan/facade-bundle

Support Facades for Symfony services.

1713.0k](/packages/indragunawan-facade-bundle)

PHPackages © 2026

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