PHPackages                             sadekbaroudi/operation-state - 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. sadekbaroudi/operation-state

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

sadekbaroudi/operation-state
============================

Handle Operation States for executable actions, with the ability to undo. i.e. transactions and rollbacks for PHP

027PHP

Since Dec 31Pushed 12y ago1 watchersCompare

[ Source](https://github.com/sadekbaroudi/operation-state)[ Packagist](https://packagist.org/packages/sadekbaroudi/operation-state)[ RSS](/packages/sadekbaroudi-operation-state/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

operation-state [![Build Status](https://camo.githubusercontent.com/9b40c65866442226c50a57dd00b09483d71fe4dd9fac9a878e68418095551900/68747470733a2f2f7472617669732d63692e6f72672f736164656b6261726f7564692f6f7065726174696f6e2d73746174652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/sadekbaroudi/operation-state) [![Coverage Status](https://camo.githubusercontent.com/69223db4a7f37f6064a1b1bf15fd16351ea78ae48839ed28b2b169361070fee1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f736164656b6261726f7564692f6f7065726174696f6e2d73746174652f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/sadekbaroudi/operation-state?branch=master) [![Dependency Status](https://camo.githubusercontent.com/784cd2d03c3f3bbebe962da5324fcf81b537d1cacc3f32991133ef8d94eb8a8a/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3532366466363233363332626163313164353030303036332f62616467652e706e67)](https://www.versioneye.com/user/projects/526df623632bac11d5000063)operation-state
====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#operation-state---operation-state)

Simple PHP classes to handle Operation States for executable actions, with the ability to undo. In other words, helper for transactions and rollbacks within PHP.

Its purpose is to provide a reliable method for executing actions, and being able to undo those actions when applicable. The functionality will allow you create multiple groups of executable actions and their respective undo actions.

Usage
=====

[](#usage)

```
use Sadekbaroudi\OperationState\OperationStateManager;
use Sadekbaroudi\OperationState\OperationState;

$yourClass = new YourClassName();

// Instantiate the manager
$osm = new OperationStateManager();

// Note that the setExecute and setUndo require PHP is_callable compliant parameters, as OperationState uses those methods
$os = new OperationState();
$os->setExecute(array($yourClass, 'yourMethod'), array('param1', $param2, array('foo' => 'bar')));
$os->setUndo(array($yourClass, 'undoMethod'), array('param1'));
$osm->add($os);

try {
    $osm->execute($os);
} catch ( OperationStateException $e ) {
    $osm->undo($os);
    throw $e;
}
```

Installation
============

[](#installation)

Operation State can be installed with [Composer](http://getcomposer.org) by adding the library as a dependency to your composer.json file.

```
{
    "require": {
        "sadekbaroudi/operation-state": "*@dev"
    }
}
```

Please refer to the [Composer's documentation](https://github.com/composer/composer/blob/master/doc/00-intro.md#introduction)for installation and usage instructions.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/299248?v=4)[Sadek Baroudi](/maintainers/sadekbaroudi)[@sadekbaroudi](https://github.com/sadekbaroudi)

---

Top Contributors

[![sadekbaroudi](https://avatars.githubusercontent.com/u/299248?v=4)](https://github.com/sadekbaroudi "sadekbaroudi (1 commits)")

### Embed Badge

![Health badge](/badges/sadekbaroudi-operation-state/health.svg)

```
[![Health](https://phpackages.com/badges/sadekbaroudi-operation-state/health.svg)](https://phpackages.com/packages/sadekbaroudi-operation-state)
```

PHPackages © 2026

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