PHPackages                             gressus/tools - 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. gressus/tools

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

gressus/tools
=============

Tools for PHP Development

v1.1.10(8mo ago)248.8k↓23.1%3PHPPHP &gt;= 5.4.0

Since Dec 11Pushed 8mo ago2 watchersCompare

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

READMEChangelog (5)DependenciesVersions (23)Used By (0)

Gressus Tools for PHP-Developers
================================

[](#gressus-tools-for-php-developers)

Gressus Tools is a collection of PHP Scripts for easy Data Manipulation, CSV read and write and Object Access.

Data Mapping
------------

[](#data-mapping)

You can map a source array to a target array and even apply filters and post converters. This can help you when programming Import-Scripts with large datasets from one format to another.

```
namespace Gressus\Tools;
require('../autoload.php');

$dataMapperService = new DataMapperService(
    array(
        'Identifier' => 'id',
        'Group + Name' => new Mapper\Concat(array(
            'group',
            new Mapper\FirstNotEmpty(array('full_name','name')))
        ),
        'Counter' => new Mapper\Counter(),
        'FirstChar' => new Mapper\FirstChar('name'),
        'Name' => new Mapper\FirstNotEmpty(array('full_name','name')),
        'Hash' => new Mapper\All(),
        'Weapons' => new Mapper\ArrayPath('special/weapons'),
    ),
    array(
          new Converter\Serialize('Hash'),
          new Converter\Md5('Hash'),
          new Converter\Implode('Weapons'),
    ),
    array(
        array('score',new Filter\GreaterThanFilter(0)),
    ),
    array(
        array('Counter',new Filter\GreaterThanFilter(1)),
    )
);

$data = array(
    array('id' => '1', 'group' => 'Police',   'name' => 'Melanie',   'score' => 1, 'full_name' => 'Melanie Meyer', 'special' => array('weapons' => array('Walter','Tonfa'))),
    array('id' => '2', 'group' => 'Police',   'name' => 'Kerstin',   'score' => 1, 'full_name' => 'Kerstin Meyer', 'special' => array('weapons' => array('Walter','Tonfa'))),
    array('id' => '3', 'group' => 'Police',   'name' => 'Thomas',    'score' => 4, 'full_name' => 'Thomas Taffil', 'special' => array('weapons' => array('Walter','Tonfa'))),
    array('id' => '5', 'group' => 'Gangster', 'name' => 'Hafti',     'score' => 10, 'special' => array('weapons' => array('Knife','AKAI 47'))),
    array('id' => '6', 'group' => 'Gangster', 'name' => 'Fler',      'score' => 0),
    array('id' => '7', 'group' => 'Press',    'name' => 'Steiger',   'score' => 0),
    array('id' => '8', 'group' => 'Press',    'name' => 'Sz',        'score' => 5),
    array('id' => '9', 'group' => 'Press',    'name' => 'Max',       'score' => 1),
    array('id' => '10','group' => 'Press',    'name' => 'Max',       'score' => 1),
);

$mappedData = $dataMapperService->map($data);

print(json_encode($mappedData,JSON_PRETTY_PRINT));
```

Output:

```
[
    {
        "Identifier": "2",
        "Group + Name": "Police Kerstin Meyer",
        "Counter": 2,
        "FirstChar": "K",
        "Name": "Kerstin Meyer",
        "Hash": "150ca40755bb997e775fcd0a94fc0147",
        "Weapons": "Walter , Tonfa"
    },
    {
        "Identifier": "3",
        "Group + Name": "Police Thomas Taffil",
        "Counter": 3,
        "FirstChar": "T",
        "Name": "Thomas Taffil",
        "Hash": "e80d48253791a5a083f2b49b0d4a7b70",
        "Weapons": "Walter , Tonfa"
    },
    {
        "Identifier": "5",
        "Group + Name": "Gangster Hafti",
        "Counter": 4,
        "FirstChar": "H",
        "Name": "Hafti",
        "Hash": "e8bf5ce0d5e2d75346b5b4e1282c47d6",
        "Weapons": "Knife , AKAI 47"
    },
    {
        "Identifier": "8",
        "Group + Name": "Press Sz",
        "Counter": 5,
        "FirstChar": "S",
        "Name": "Sz",
        "Hash": "8ad9d3eae1f9fa75fdbcb3fbd0bac00e",
        "Weapons": null
    },
    {
        "Identifier": "9",
        "Group + Name": "Press Max",
        "Counter": 6,
        "FirstChar": "M",
        "Name": "Max",
        "Hash": "8a85c8790f0029a12584bec43c1734d0",
        "Weapons": null
    },
    {
        "Identifier": "10",
        "Group + Name": "Press Max",
        "Counter": 7,
        "FirstChar": "M",
        "Name": "Max",
        "Hash": "9b5b1d4c5ca965f0d2bcd4e039b48cba",
        "Weapons": null
    }
]
```

Data Reducing
-------------

[](#data-reducing)

(behaves like MySQL group by on PHP Arrays)

```
namespace Gressus\Tools;
require('../autoload.php');

$reducer = new ReducerService(
    'group',
    array(
        'id' => new Reducer\ConcatReducer(),
        'name' => new Reducer\ConcatReducer(array('distinct' => true)),
        'score' => new Reducer\SumReducer(),
    ),
    array(
        array('score',new Filter\GreaterThanFilter(0)),
        array('score',new Filter\LowerThanFilter(10)),
    )
);

$data = array(
    array('id' => '1','group' => 'Police', 'name' => 'Melanie','score' => 1),
    array('id' => '2','group' => 'Police', 'name' => 'Kerstin','score' => 1),
    array('id' => '3','group' => 'Police', 'name' => 'Thomas','score' => 4),
    array('id' => '5','group' => 'Gangster', 'name' => 'Hafti','score' => 10),
    array('id' => '6','group' => 'Gangster', 'name' => 'Fler','score' => 0),
    array('id' => '7','group' => 'Press', 'name' => 'Steiger','score' => 0),
    array('id' => '8','group' => 'Press', 'name' => 'Sz','score' => 5),
    array('id' => '9','group' => 'Press', 'name' => 'Max','score' => 1),
    array('id' => '10','group' => 'Press', 'name' => 'Max','score' => 1),
);

$reducedData = $reducer->reduce($data);

print(json_encode($reducedData,JSON_PRETTY_PRINT));
```

Output:

```
{
    "Police": {
        "id": "1, 2, 3",
        "name": "Melanie, Kerstin, Thomas",
        "score": 6
    },
    "Press": {
        "id": "8, 9, 10",
        "name": "Sz, Max",
        "score": 7
    }
}
```

Read CSV Data
-------------

[](#read-csv-data)

```
namespace Gressus\Tools;
require('../autoload.php');

$csvService = new CsvService();

$csvService->read('../Data/example-data.csv');

print_r($csvService->getAssociatedArrayData());
```

Write CSV Data
--------------

[](#write-csv-data)

```
namespace Gressus\Tools;
require('../autoload.php');

$data = array(
    array('id' => '1', 'group' => 'Police',   'name' => 'Melanie',   'score' => 1, 'full_name' => 'Melanie Meyer'),
    array('id' => '2', 'group' => 'Police',   'name' => 'Kerstin',   'score' => 1, 'full_name' => 'Kerstin Meyer'),
    array('id' => '3', 'group' => 'Police',   'name' => 'Thomas',    'score' => 4, 'full_name' => 'Thomas Thiel'),
    array('id' => '5', 'group' => 'Gangster', 'name' => 'Hafti',     'score' => 10,),
    array('id' => '6', 'group' => 'Gangster', 'name' => 'Fler',      'score' => 0),
    array('id' => '7', 'group' => 'Press',    'name' => 'Steiger',   'score' => 0),
    array('id' => '8', 'group' => 'Press',    'name' => 'Sz',        'score' => 5),
    array('id' => '9', 'group' => 'Press',    'name' => 'Max',       'score' => 1),
    array('id' => '10','group' => 'Press',    'name' => 'Max',       'score' => 1),
);

$csvService = new CsvService();
$csvService
    ->setAssociatedArrayData($data)
    ->setFileName('../Data/example-data-write.csv')
    ->write();
```

Credits
-------

[](#credits)

Many Thanks to [TUDOCK](http://www.tudock.de). I originally started the development of these Tools working in the nice office at TUDOCK.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance61

Regular maintenance activity

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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 ~178 days

Recently: every ~453 days

Total

21

Last Release

249d ago

PHP version history (2 changes)1.0.0PHP 5.4.0

1.0.1PHP &gt;= 5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/82cca472fdb2594150c48063464e92fb3f469c5f805418083d36d4bf2d492c40?d=identicon)[gressus](/maintainers/gressus)

---

Top Contributors

[![bazen](https://avatars.githubusercontent.com/u/3831024?v=4)](https://github.com/bazen "bazen (6 commits)")[![mdoelker](https://avatars.githubusercontent.com/u/2145319?v=4)](https://github.com/mdoelker "mdoelker (2 commits)")[![mguettler](https://avatars.githubusercontent.com/u/821149?v=4)](https://github.com/mguettler "mguettler (1 commits)")[![tobiasthaden](https://avatars.githubusercontent.com/u/2782913?v=4)](https://github.com/tobiasthaden "tobiasthaden (1 commits)")

### Embed Badge

![Health badge](/badges/gressus-tools/health.svg)

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

###  Alternatives

[powder96/numbers.php

Advanced Mathematics Library for PHP (port of Numbers.js)

15844.0k1](/packages/powder96-numbersphp)

PHPackages © 2026

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