PHPackages                             yarimadam/phpcor - 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. yarimadam/phpcor

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

yarimadam/phpcor
================

Simple chain of responsibility implementation written in PHP.

0.1.1(7y ago)510MITPHPPHP &gt;7

Since Nov 7Pushed 7y agoCompare

[ Source](https://github.com/yarimadam/phpcor)[ Packagist](https://packagist.org/packages/yarimadam/phpcor)[ RSS](/packages/yarimadam-phpcor/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Chain of Responsibility with PHP
================================

[](#chain-of-responsibility-with-php)

Description
-----------

[](#description)

Yarimadam/COR package is a simple chain of responsibility implementation written in PHP. It allows you to define handlers for each contex of your subjects and helps you with better modularizing your conditionals by decreasing cyclomatic/npath complexity in your applications.

Installation
------------

[](#installation)

If you are crazy enough not to use composer, just download/clone it.

Otherwise, install with composer.

```
composer require yarimadam/phpcor

```

Quick Start
-----------

[](#quick-start)

### Define Handlers

[](#define-handlers)

Create respective handlers for each contex of your subject, by extending `\Yarimadam\COR\AbstractHandler` superclass.

#### Handler Examples

[](#handler-examples)

Execute when passed subject is type of a "string":

```
class StringHandler extends AbstractHandler
{
    protected function isResponsible($subject): bool
    {
        return is_string($subject);
    }

    protected function process($subject): void
    {
        // echo the output
        echo 'We have a string here!';
    }
}
```

Execute when passed subject is type of an "array".

```
class ArrayHandler extends AbstractHandler
{
    protected function isResponsible($subject): bool
    {
        return is_array($subject);
    }

    protected function process($subject): void
    {
        $output = [];
        foreach($subject as $item) {
            $output[] = $item;
        }
        // don't echo, set as handler output instead
        $this->chain->setResponsibleHandlerOutput($output);
    }
}
```

### Define Flow

[](#define-flow)

```
$cor = new ChainOfResponsibility();

$cor->registerHandler(new StringHandler());
$cor->registerHandler(new ArrayHandler());

$subject = 'Hi there, i\'m a string!';

$cor->processThroughChain($subject);
```

### Get Results

[](#get-results)

```
// fully qualified class name
$cor->getResponsibleHandler();

// output from the handler - if any
$cor->getResponsibleHandlerOutput();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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 ~82 days

Total

2

Last Release

2663d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b8ca9e5017ebe63224d5fcf8e9fc86aa52705a751275455062a5545d7baf61f?d=identicon)[yarimadam](/maintainers/yarimadam)

---

Top Contributors

[![yarimadam](https://avatars.githubusercontent.com/u/11577053?v=4)](https://github.com/yarimadam "yarimadam (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/yarimadam-phpcor/health.svg)

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

###  Alternatives

[magefan/module-auto-related-product

Extend native Magento Up-Sells, Cross-Sells, and Related products

1834.7k2](/packages/magefan-module-auto-related-product)[klisl/laravel-widgets

Package for using widgets in Laravel-5

103.7k](/packages/klisl-laravel-widgets)

PHPackages © 2026

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