PHPackages                             carlosv2/communism - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. carlosv2/communism

ActiveLibrary[Testing &amp; Quality](/categories/testing)

carlosv2/communism
==================

Little utility to easily extract and inject properties from objects

1.2.3(9y ago)03.3k2MITPHPPHP ~5.3 || ~7.0

Since Dec 12Pushed 9y ago1 watchersCompare

[ Source](https://github.com/carlosV2/Communism)[ Packagist](https://packagist.org/packages/carlosv2/communism)[ RSS](/packages/carlosv2-communism/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (2)

Communism
=========

[](#communism)

Little utility to easily extract and inject properties from objects.

[![License](https://camo.githubusercontent.com/704fc70a68b2787740474d42ea1da2b7b930fec0bc9c38e7a26d5f54cd664855/68747470733a2f2f706f7365722e707567782e6f72672f6361726c6f7376322f636f6d6d756e69736d2f6c6963656e7365)](https://packagist.org/packages/carlosv2/communism)[![Build Status](https://camo.githubusercontent.com/7afa4f4456e17755bf41b069743e16d8500534e98a422f53abe2538b3acd7d73/68747470733a2f2f7472617669732d63692e6f72672f6361726c6f7356322f436f6d6d756e69736d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/carlosV2/Communism)[![SensioLabsInsight](https://camo.githubusercontent.com/0d4283da1dc3d1bc3c156f589f9b974b433ae74ba5639ee7c16ffb519c85dd26/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f32316438386432352d626539382d346538632d383662642d3837363262346562623033392f6d696e692e706e67)](https://insight.sensiolabs.com/projects/21d88d25-be98-4e8c-86bd-8762b4ebb039)

Usage
-----

[](#usage)

If you want to extract any object property, use one of the following constructions:

```
$value = From($object)->property;
// or
$value = From($object)->extract('property');
```

If you want to inject any object property, use one of the following constructions:

```
To($object)->property = $value;
// or
To($object)->inject('property', $value);
```

If you want to replace any object property, use one of the following constructions:

```
// The `replace` method is avilable for both `From` and `To`
From($object)->property(function ($value) {
    // `$value` will contain the current value for that property

    // Whatever is returned will be the new value of the property
    return $newValue;
});
// or
From($object)->replace('property', function ($value) {
    // `$value` will contain the current value for that property

    // Whatever is returned will be the new value of the property
    return $newValue;
});
```

Both functions `From` and `To` instantiate a `carlosV2\Communism\Communist` object which allows the extraction and injection of properties.

Words of wisdom
---------------

[](#words-of-wisdom)

This project is designed to be used for development environment only. If you find yourself using this project on production code, you should better reconsider your architecture.

Install
-------

[](#install)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this project:

```
$ composer require --dev carlosv2/communism
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

6

Last Release

3424d ago

PHP version history (2 changes)1.0.0PHP ~5.4 || ~7.0

1.2.1PHP ~5.3 || ~7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2642839?v=4)[Carlos Ortega](/maintainers/carlosV2)[@carlosV2](https://github.com/carlosV2)

---

Top Contributors

[![carlosV2](https://avatars.githubusercontent.com/u/2642839?v=4)](https://github.com/carlosV2 "carlosV2 (14 commits)")

---

Tags

testreflectionproperty

### Embed Badge

![Health badge](/badges/carlosv2-communism/health.svg)

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

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k516.1M26.2k](/packages/mockery-mockery)[hamcrest/hamcrest-php

This is the PHP port of Hamcrest Matchers

7.0k503.3M117](/packages/hamcrest-hamcrest-php)[nelmio/alice

Expressive fixtures generator

2.5k44.6M155](/packages/nelmio-alice)[nyholm/nsa

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

2286.2M85](/packages/nyholm-nsa)[zenstruck/foundry

A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.

79513.1M132](/packages/zenstruck-foundry)[php-mock/php-mock

PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.

36919.3M119](/packages/php-mock-php-mock)

PHPackages © 2026

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