PHPackages                             root4root/reshaper - 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. root4root/reshaper

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

root4root/reshaper
==================

Reshaper for arrays

1.0.3(7y ago)034MITPHPPHP &gt;=5.4.0

Since Apr 11Pushed 7y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Reshaper
========

[](#reshaper)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Build Status](https://camo.githubusercontent.com/d5f11a32d2c296fd651fd266ab54bc5c2f17198a487a86bb2dd575cbbb21d2f3/68747470733a2f2f7472617669732d63692e6f72672f726f6f7434726f6f742f72657368617065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/root4root/reshaper)

Implements primitive language which helps transform arrays (rows) i.e. exclude some values (members) or mix them. As a result, you could get array that bigger or smaller than original one.

Library was developed for convinient way to filtering data came from xlsx parser, or any. Language simplicity allows to involve end customers, so they can write filters without help from programmers. That's why A,B,C etc as columns names. Digits are also acceptible, but indexes begins from 1. First element, second and so on.

### Quick examle

[](#quick-examle)

```
require_once ('vendor/autoload.php');

use Root4root\Reshaper\Configurator;
use Root4root\Reshaper\Reshaper;

$fields = ['(A)i','(B)s', '(B+C)s'];
$requiredCols = ['(A)i', '(G|H|I)r(/^(?:\s*)[1-9,\+]+(?:\s*)$/)'];

$dataRow = [1, 'PARTNUMBER', 'Part.333', 'Description', 'foo1', 'foo2', '+', 0, 0];

$config = new Configurator($fields, $requiredCols);
$reshaper = new Reshaper($config);

$output = $reshaper->parseRow($dataRow);

print_r($output->getResult());

/*
 * Array
 * (
 *     [0] => 1
 *     [1] => PARTNUMBER
 *     [2] => PARTNUMBER Part.333
 * )
 */
```

### Explanation

[](#explanation)

There are two arrays for configuration. First one is answering the question «What fields are expected to be created with the output array?» Second formulates rules for validation.

##### Fields array syntax ($fields in example)

[](#fields-array-syntax-fields--in-example)

###### (column)type(extra)

[](#columntypeextra)

Columns can be separated by a special chars: +, -, \*, /.

Types from package:

- f - float
- i - integer
- r - regular expression
- s - string

Extra: some additional configuration, required for ‘r’ processor. Can be used with ‘i’ and ‘f’ by optional.

Each type handles with certain processor, with its own validation and filed rules. For example, processor 's' will concatenate fields, regardless of separator (B+C) or (B\*C). Processor 'i' (integer) and 'f' will calculate the result depending on the math sign.

(A)i(30) - get value from column, convert it to integer and increase by 30%. Same operation with the float type.

You can specify columns by number, starting from 1 (first). Example: '(2+3)s' == '(B+C)s'

##### Required array syntax ($requiredCols in example)

[](#required-array-syntax-requiredcols-in-example)

###### (column)type(extra)

[](#columntypeextra-1)

Columns separators: |,&amp; (or +,\* respectevly).

Types: f,i,r,s from package.

(A|B)i - A **or** B must be &gt; 0

(A&amp;B)s - A **and** B is not empty strings

(G|H)r(regexp) - A **or** B must satisfy regular expression.

**You should specify required array or its equivalents to field list. This can cause a problem with performance.**

### Your own types

[](#your-own-types)

You can define your own data types or override defaults from package. Create class Processor\_type, which implements the Processor Interface.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Total

4

Last Release

2701d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.0.3PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11481734?v=4)[root4root](/maintainers/root4root)[@root4root](https://github.com/root4root)

---

Top Contributors

[![root4root](https://avatars.githubusercontent.com/u/11481734?v=4)](https://github.com/root4root "root4root (10 commits)")

---

Tags

arraysreshaper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/root4root-reshaper/health.svg)

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

###  Alternatives

[ilya/belt

A handful of tools for PHP developers.

70820.9k1](/packages/ilya-belt)[minwork/array

Pack of advanced array functions specifically tailored for: associative (assoc) array, multidimensional array, array of objects and handling nested array elements

66268.2k5](/packages/minwork-array)[sarhan/php-flatten

Flattens multidimensional arrays, traversables and vars into one dimensional array.

21182.2k1](/packages/sarhan-php-flatten)[dotty/dotty

Easy access to array data using dot notation

1293.8k1](/packages/dotty-dotty)[rotexsoft/versatile-collections

A collection package that can be extended to implement things such as a Dependency Injection Container, RecordSet objects for housing database records, a bag of http cookies, or technically any collection of items that can be looped over and whose items can each be accessed using array-access syntax or object property syntax.

186.1k1](/packages/rotexsoft-versatile-collections)[glowy/arrays

Arrays Component provide a fluent, object-oriented interface for working with arrays, allowing you to chain multiple arrays operations together using a more readable syntax compared to traditional PHP arrays functions.

153.2k3](/packages/glowy-arrays)

PHPackages © 2026

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