PHPackages                             proteins/map - 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. proteins/map

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

proteins/map
============

Handle a repository of key-values data

1.0.4(6y ago)1512MITPHPPHP ^7.2

Since May 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/php-protein/map)[ Packagist](https://packagist.org/packages/proteins/map)[ RSS](/packages/proteins-map/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (5)Used By (2)

[![](https://raw.githubusercontent.com/php-protein/docs/master/assets/protein-large.png)](https://raw.githubusercontent.com/php-protein/docs/master/assets/protein-large.png)

Protein | Map
=============

[](#protein--map)

Handle a repository of key-values data
--------------------------------------

[](#handle-a-repository-of-key-values-data)

### Install

[](#install)

---

```
composer require proteins/map

```

Require the class via :

```
use Proteins\Map;
```

### Building a Dictionary

[](#building-a-dictionary)

---

Dictionary is a behaviour class, it must be extended by another class or the value repository will be shared.

```
class State extends Dictionary {}
```

### Setting a value

[](#setting-a-value)

---

You can set a value from a key path via the `get` method.

A valid key path is a arbitrary deep sequence of `.` separated strings.

**Examples**

- `test`
- `alpha.beta`
- `pages.section.text_block.3`

```
State::set('options.use_cache',false);

State::set('users.whitelist',[
	'frank.ciccio',
	'walter.submarine',
	'pepen.spacca',
]);
```

### Getting a value

[](#getting-a-value)

---

You can get a value from a key path via the `get` method.

```
echo State::get('users.whitelist.1'); // walter.submarine
```

You can optionally pass a default value to be returned when the requested key is not found. If a callable is passed the returned value will be used.

```
print_r( State::get('a.test',['b'=>123]) ); // Array( [b] => 123 )
echo State::get('a.test.b'); // 123
```

### Getting all values

[](#getting-all-values)

---

You can get all key-values as an associative array via the `all` method.

```
$all_data = State::all();
```

Results :

```
Array (
    [users] => Array (
        [whitelist] => Array(
            [0] => frank.ciccio
            [1] => walter.submarine
            [2] => pepen.spacca
        )
    )
)
```

### Clearing the Map

[](#clearing-the-map)

---

You can clear all values from a Map via the `clear` method.

```
State::clear();
```

### Merging data

[](#merging-data)

---

The `merge` method extends the Map with values passed via an associative array. The second optional parameter will define the if merge data from right-to-left or backwise (default is false = left-to-right ).

**Setting initial data**

```
State::clear();
State::merge([
    'user' => [
        'name' => 'Simon',
        'role' => 'Villain',
    ],
]);
```

```
Array (
    [user] => Array (
            [name] => Simon
            [role] => Villain
        )
)
```

**Standard merge (left-to-right)**

```
State::merge([
    'user' => [
        'name' => 'Frank',
    ],
    'happy' => true,
]);
```

```
Array (
    [user] => Array (
            [name] => Frank
            [role] => Villain
        )
    [happy] => 1
)
```

**Back merge (right-to-left)**

```
State::merge([
    'user' => [
        'name' => 'Frank',
    ],
    'happy' => true,
],true);
```

```
Array (
    [user] => Array (
            [name] => Simon
            [role] => Villain
        )
    [happy] => 1
)
```

### Getting multiple values

[](#getting-multiple-values)

---

You can retrieve multiple values, minimizing function calls by passing an associative array of type :

```
DESTINATION_KEY => Map_PATH

```

**Example** :

```
MyService::init([
    'username'   =>  State::get('aws.username'),
    'password'   =>  State::get('aws.password'),
    'from'       =>  State::get('user.email'),
    'verbose'    =>  State::get('app.global.debug'),
]);

```

Can be written with a single call to `get` as :

```
MyService::init( State::get([
    'username'   =>  'aws.username',
    'password'   =>  'aws.password',
    'from'       =>  'user.email',
    'verbose'    =>  'app.global.debug',
]));

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

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

Total

4

Last Release

2542d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b00a7323d0ef535e352696bc141305b3928fce777a0f477109d2274ad17cdb9f?d=identicon)[lastguest](/maintainers/lastguest)

---

Top Contributors

[![lastguest](https://avatars.githubusercontent.com/u/178900?v=4)](https://github.com/lastguest "lastguest (3 commits)")

### Embed Badge

![Health badge](/badges/proteins-map/health.svg)

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

###  Alternatives

[pyrech/composer-changelogs

Display changelogs after each composer update

5904.0M25](/packages/pyrech-composer-changelogs)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[geocoder-php/plugin

Plugins to Geocoder providers

705.1M2](/packages/geocoder-php-plugin)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[pocketmine/bedrock-block-upgrade-schema

Schemas describing how to upgrade saved block data in older Minecraft: Bedrock Edition world saves

23355.4k5](/packages/pocketmine-bedrock-block-upgrade-schema)

PHPackages © 2026

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