PHPackages                             new-inventor/data-structure - 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. new-inventor/data-structure

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

new-inventor/data-structure
===========================

Data structure transformers and validators config

3.1.5(8y ago)03591MITPHPPHP ^7.1

Since Oct 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/new-inventor/data-structure)[ Packagist](https://packagist.org/packages/new-inventor/data-structure)[ RSS](/packages/new-inventor-data-structure/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (9)Versions (36)Used By (1)

Property bag
============

[](#property-bag)

This utility provide to you data structure metadata and some useful classes.

With this packet you can transform arrays to needed format and load it to objects recursive.

**Objects to load** MUST implement Loadable or DataStructureInterface interface.

#### Installation

[](#installation)

composer require new-inventor/data-structure

Examples
--------

[](#examples)

### Metadata config

[](#metadata-config)

```
namespace: DataStructure\Namespace
validation:
  constraints:
    - Callback: ['Some\Existing\Class', 'GetTrue']
  getters:
    prop1:
      - GreaterThan: 0
  properties:
    prop0:
      - GreaterThan: 0
properties:
  prop1: NewInventor\DataStructure\Transformer\ToInt
  prop2:
    transformers:
      - ToInt: ~
    validation:
      - GreaterThan: 5
      - LessThanOrEqual: 1000
  prop3:
    transformers:
      - ToBool:
          - ['Some\Existing\Class', 'GetTrue']
  prop4:
    transformers:
      - ToBool:
          - groups: forward
      - BoolToMixed:
          - static: ['Some\Existing\Class', 'bbb']
          - const: ['Some\Existing\Class', 'AAA']
          - groups: backward
  prop5: ~
  prop6:
    transformers:
      - ChainTransformer:
          - ToString: ~
          - CsvStringToArray: ~
          - NewInventor\DataStructure\Transformer\InnerTransformer:
              - ToInt: ~
          - groups: forward
      - ArrayToCsvString:
          - groups: backward
  prop7:
    default: 2222
    transformers:
      - ToString: ~
      - StringToDateTime:
          - 'd.m.Y'
          - groups: forward
  prop8:
    transformers:
      - ToArray:
          - groups: forward
  prop9:
    nested:
      class: DataStructure\Namespace\Structure
```

#### Recursive loading

[](#recursive-loading)

You can load properties recursive by using RecursiveConstructor.

To use this you shoul add `nested` parameter to property like this

```
prop:
  nested:
    class: DataStructure\Namespace\Structure
```

or

```
prop:
  nested:
    metadata:
      path: some/config
      baseNamespace: Some\Namespace
    class: DataStructure\Namespace\Structure
```

or

```
prop:
  nested:
    metadata:
      path: some/config/path.yml
    class: DataStructure\Namespace\Structure
```

#### Namespace

[](#namespace)

It is the namespace for data structure class for recursive loading.

#### Validation

[](#validation)

It is the symfony class validation config. You can pass it directly into property

#### Properties

[](#properties)

It is properties of your data structure.

Property has this parameters:

- default
- transformers
- validation
- nested

If property === null(~) then default = null and no transformers and validators If property is string then default = null and default transformers = this string

##### transformers

[](#transformers)

Transformers is array of arrays.

In yml like this:

```
key:
  - name: value
```

So you can set transformer like this:

```
transformers:
  - ToInt: ~
```

By default transformer is inner transformer, but you can create you own and pass full class name to transformer config

Transformer can receive array or parameters and parameter can be array(1) with reserved word as key; Reserved words:

- static - interpret as static property of class `['class', 'propertyName']`
- const - interpret as constant can be array like static or string
- groups - transformer groups, by default `groups = ['default']`.

If in transformers section more than 1 transformer in same group then this transformers will be wrapped by ChainTransformer, so this identical:

```
transformers:
  - ToInt:
      - groups: group1
  - ToRange:
      - 1
      - 10
      - groups: group1
```

and

```
transformers:
  - ChainTransformer:
      - groups: group1
      - ToInt:
      - ToRange:
          - 1
          - 10
```

##### Validation

[](#validation-1)

It is the getters part of symfony validation config for given property

##### Default

[](#default)

Default can be any value and have same reserved keys as transformer parameters, but group.

##### Nested

[](#nested)

It is described in Recursive loading section.

### PropertiesTransformer

[](#propertiestransformer)

```
$metadata = (new Metadata\Loader($path))->loadMetadata();
$transformer = $metadata->getTransformer($groupName);
$resArray = $transformer->transform($someArray);
```

or you can compose PropertiesTransformer by yourself

### RecursiveConstructor

[](#recursiveconstructor)

This constructor construct class with metadata by recursive loading it nested classes.

Links
-----

[](#links)

- To use only transformers use
- To implement property bags use

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

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

Recently: every ~19 days

Total

35

Last Release

3038d ago

Major Versions

1.4.1 → 2.0.02017-10-12

2.3.0 → 3.0.02017-11-02

3.0.0 → 4.0.0.x-dev2017-11-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/2084172da990b68442d9b2af5c9cd30a006522fc74984a586b02066168f89733?d=identicon)[George Ionov](/maintainers/George%20Ionov)

---

Top Contributors

[![new-inventor](https://avatars.githubusercontent.com/u/4446486?v=4)](https://github.com/new-inventor "new-inventor (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/new-inventor-data-structure/health.svg)

```
[![Health](https://phpackages.com/badges/new-inventor-data-structure/health.svg)](https://phpackages.com/packages/new-inventor-data-structure)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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