PHPackages                             dantleech/cellular - 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. dantleech/cellular

Abandoned → [phpbench/cellular](/?search=phpbench%2Fcellular)Library[Utility &amp; Helpers](/categories/utility)

dantleech/cellular
==================

Represent and analyze tabular data

0.3(10y ago)1178[1 PRs](https://github.com/phpbench/cellular/pulls)MITPHPPHP ~5.4

Since May 17Pushed 10y ago1 watchersCompare

[ Source](https://github.com/phpbench/cellular)[ Packagist](https://packagist.org/packages/dantleech/cellular)[ RSS](/packages/dantleech-cellular/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (8)Used By (0)

Cellular
========

[](#cellular)

**ABANDONED**: Use Tabular instead.

[![Build Status](https://camo.githubusercontent.com/10170648a23ff76ce3e8022a058075079ac4178dbd581ca649bc4286c0dfd0a6/68747470733a2f2f7472617669732d63692e6f72672f64616e746c656563682f63656c6c756c61722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dantleech/cellular) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/6f5a0446d9091146f9b6db3161ccabc4e33f487784d994d1ff47992cad35b5b9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e746c656563682f63656c6c756c61722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dantleech/cellular/?branch=master)

The cellular library provides an object oriented way of building, representing and analyzing tabular data.

Features:

- Supports aggregate functions `sum`, `avg`, `min`, `max` and `median`.
- Aggreate functions can applied to `Table`, `Row` and `Column`.
- Supports cell groups.
- Callbacks can be applied to cells on whole, or selected groups of `Table`, `Row` and `Column` instances.
- Produce grouped tables with callbacks - analagous to `SELECT bar, SUM(foo) FROM sometable GROUP BY bar`
- Fluent table builder

Note that this library is under development.

Creating
--------

[](#creating)

Col 1Col 2Col 31214412144Would be created as follows:

```
$table = Table::create();
$table->createAndAddRow()
    ->set('col1', 12)
    ->set('col2', 14)
    ->set('col3', 4);
$table->createAndAddRow()
    ->set('col1', 12)
    ->set('col2', 14)
    ->set('col3', 4)
```

Or without the builder:

```
$table = new Table(
     new Row(array(
         'col1' => new Cell(12),
         'col2' => new Cell(14),
         'col3' => new Cell(4),
     )),
     new Row(array(
         'col1' => new Cell(12),
         'col2' => new Cell(14),
         'col3' => new Cell(4),
     )),
 );
```

Retrieving cell values
----------------------

[](#retrieving-cell-values)

You can retrieve values from `Table`, `Row` and `Column` instances as follows:

```
$table->getValues(); // return an array containg all cell values
$table->getRow(0)->getValues();
$table->getColumn('col1')->getValues();
```

Groups
------

[](#groups)

You apply groups to cells:

```
$table->createAndAddRow()
    ->set('hello, 'vaue', array('group1'));

var_dump($table->getCells(array('group1'))); // dump all cells in group1

$table->mapValues(function ($value) {
    return 'goodbye';
}, array('group1')); // set the value of all cells in group1 to "goodbye"
```

Using the Calculator
--------------------

[](#using-the-calculator)

The calculator allows you to apply certain calculations to values, `Cell`instances or any instance of `CellularInterface`:

```
$mean = Calculator::mean($table); // return the mean (average) value of the table

$median = Calculator::median($table->getRow(0)); // return the median value of the first row

$deviation = Calculator::deviation(
    Calculator::mean($table->getColumn('col1')),
    $table->getRow(0)->getCell('col1')
); // return the deviation of "col1" in the first row as a percentage from the average value of "col1"
```

Current functions:

- `sum`: Return the sum of values
- `min`: Return the minimum value
- `max`: Return the maximum value
- `mean`: Return the mean (average) value
- `median`: Return the median value
- `deviation`: Return the deviation as a percentage

Partitioning and Forking
------------------------

[](#partitioning-and-forking)

`Table` and `Row` instances provide the following methods:

- `partition`: Internally divide the collection of elements according to a given callback.
- `aggregate`: Aggregate the partitions of a table back to a single partition.

This is useful for creating summaries from multiple tables or rows:

For example:

```
$table
    ->partition(function ($row) {
        return $row['class'];
    })
    ->partition(function ($table, $newInstance) use ($cols, &$newCols, $options, $functions) {
        $newInstance->createAndAddRow()
            ->set(
                'number',
                Calculator::sum($table->getColumn('number'))
            );
    });
```

The callback is passed each partition in turn alongisde a new instance of the collection class. The callback's responsiblity is to add new rows to the new instance, the primary partition of which will become the new primary partition for the collection upon which the operation is performed.

The result will be anagous to the following SQL: `SELECT SUM(number) FROM table GROUP BY class`.

Sorting
-------

[](#sorting)

Sorting can be achieved as follows:

```
$table->sort(function ($row1, $row2) {
    return $row1['col1'] > $row2['col1'];
});
```

Evaluating values
-----------------

[](#evaluating-values)

Values can be evaluated as follows:

```
$sum = $table->evaluate(function ($row, $lastValue) {
    $lastValue += $row['cell']->getValue();
}, 0); // evaluates the sum of the column "cell"
```

The callback is passed the element and the previous result. The initial result is given as the second argument to `evaluate`.

Setting Attributes
------------------

[](#setting-attributes)

It is possible to set attributes on `Cell` and `Cellular` instances. This is useful when you need to store metadata about the source of the data before it was transformed into cellular form.

```
$table->setAttribute('foo', 'bar');
$table->getAttribute('foo');
$table->hasAttribute('foo');
```

Other methods
-------------

[](#other-methods)

- `filter`: Filter the results by a closure. Returns a new instance.
- `clear`: Clear the collection

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

4

Last Release

3988d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/24ec7d5d6b7ea54007be5d7b4f43800381cc1e22929f7d2276fba30e497fdfa6?d=identicon)[dantleech](/maintainers/dantleech)

---

Top Contributors

[![dantleech](https://avatars.githubusercontent.com/u/530801?v=4)](https://github.com/dantleech "dantleech (70 commits)")

### Embed Badge

![Health badge](/badges/dantleech-cellular/health.svg)

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

###  Alternatives

[phpmentors/stagehand-fsm

A finite state machine

361.1k](/packages/phpmentors-stagehand-fsm)

PHPackages © 2026

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