PHPackages                             fg/parkour - 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. fg/parkour

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

fg/parkour
==========

A collection of utilities to manipulate arrays.

1.1.1(10y ago)15501.7k↑33.7%4[1 issues](https://github.com/felixgirault/parkour/issues)3BSD-2-ClausePHPPHP &gt;=5.5.0

Since Aug 9Pushed 10y ago4 watchersCompare

[ Source](https://github.com/felixgirault/parkour)[ Packagist](https://packagist.org/packages/fg/parkour)[ Docs](http://github.com/felixgirault/parkour)[ RSS](/packages/fg-parkour/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (1)Versions (4)Used By (3)

Parkour
=======

[](#parkour)

[![Build status](https://camo.githubusercontent.com/b03bbbded35530cf49ca160b976c036b7136801968f8a9ffb2a13246c6b64cde/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f66656c697867697261756c742f7061726b6f75722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](http://travis-ci.org/felixgirault/parkour)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/48ce0ff110574c9107854bcfa03aaa2464279c3cc3ea9e83e0c797311b89fff7/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f66656c697867697261756c742f7061726b6f75722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/felixgirault/parkour/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/57d0347530c3fd4b73506143fa73c56a69772aa773589c6ad2003aaee7458d0d/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f66656c697867697261756c742f7061726b6f75722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/felixgirault/parkour/?branch=master)

A collection of utilities to manipulate arrays.

The aim of this library is to provide a consistent API, unlike the one natively implemented in PHP.

Examples
--------

[](#examples)

Using your own functions:

```
Parkour\Traverse::filter([5, 15, 20], function($value) {
	return $value > 10;
});

// [15, 20]
```

Using some of the built-in functors:

```
Parkour\Traverse::filter([5, 15, 20], new Parkour\Functor\Greater(10));
// [15, 20]

Parkour\Traverse::map([10, 20], new Parkour\Functor\Multiply(2), 0);
// [20, 40]

Parkour\Traverse::reduce([10, 20], new Parkour\Functor\Add(), 0);
// 30
```

API
---

[](#api)

### Traverse

[](#traverse)

```
use Parkour\Traverse;
```

[each()](#each), [map()](#map), [mapKeys()](#mapKeys), [filter()](#filter), [reject()](#reject), [reduce()](#reduce), [find()](#find), [findKey()](#findKey), [some()](#some), [every()](#every).

#### each()

[](#each)

```
Traverse::each(['foo' => 'bar'], function($value, $key) {
	echo "$key: $value";
});

// foo: bar
```

#### map()

[](#map)

```
$data = [
	'foo' => 1,
	'bar' => 2
];

Traverse::map($data, function($value, $key) {
	return $value * 2;
});

// [
// 	'foo' => 2,
// 	'bar' => 4
// ]
```

#### mapKeys()

[](#mapkeys)

```
$data = [
	'foo' => 1,
	'bar' => 2
];

Traverse::mapKeys($data, function($value, $key) {
	return strtoupper($key);
});

// [
// 	'FOO' => 1,
// 	'BAR' => 2
// ]
```

#### filter()

[](#filter)

```
$data = [
	'foo' => true,
	'bar' => false
];

Traverse::filter($data, function($value, $key) {
	return $value === true;
});

// [
// 	'foo' => true
// ]
```

#### reject()

[](#reject)

```
$data = [
	'foo' => true,
	'bar' => false
];

Traverse::reject($data, function($value, $key) {
	return $value === true;
});

// [
// 	'bar' => false
// ]
```

#### reduce()

[](#reduce)

```
Traverse::reduce([1, 2], function($memo, $value, $key) {
	return $memo + $value;
}, 0);

// 3
```

Using built-in functors:

```
Traverse::reduce([1, 2], new Parkour\Functor\Add(), 0); // 3
Traverse::reduce([2, 2], new Parkour\Functor\Mutiply(), 2); // 8
```

#### find()

[](#find)

```
$data = [
	'foo' => 'PHP',
	'bar' => 'JavaScript'
];

Traverse::find($data, function($value, $key) {
	return $key === 'foo';
});

// 'PHP'
```

#### findKey()

[](#findkey)

```
$data = [
	'foo' => 'PHP',
	'bar' => 'JavaScript'
];

Traverse::findKey($data, function($value, $key) {
	return $value === 'PHP';
});

// 'foo'
```

#### some()

[](#some)

```
Traverse::some([5, 10, 20], function($value, $key) {
	return $value > 10;
});

// true
```

Using a built-in functor:

```
Traverse::some([1, 2], new Parkour\Functor\AlwaysFalse()); // false
```

#### every()

[](#every)

```
Traverse::every([1, 2], function($value, $key) {
	return $value === 1;
});

// false
```

Using a built-in functor:

```
Traverse::every([1, 2], new Parkour\Functor\AlwaysTrue()); // true
```

### Transform

[](#transform)

```
use Parkour\Transform;
```

[combine()](#combine), [normalize()](#normalize), [reindex()](#reindex), [merge()](#merge).

#### combine()

[](#combine)

```
$data = [
	['id' => 12, 'name' => 'foo'],
	['id' => 37, 'name' => 'bar']
];

Transform::combine($data, function($row, $key) {
	yield $row['id'] => $row['name'];
});

// [
// 	12 => 'foo',
// 	37 => 'bar'
// ]
```

#### normalize()

[](#normalize)

```
$data = [
	'foo' => 'bar'
	'baz'
];

Transform::normalize($data, true);

// [
// 	'foo' => 'bar',
// 	'baz' => true
// ]
```

#### reindex()

[](#reindex)

```
$data = ['foo' => 'bar'];

Transform::reindex($data, [
	'foo' => 'baz'
]);

// [
// 	'baz' => 'bar'
// ]
```

#### merge()

[](#merge)

```
$first = [
	'one' => 1,
	'two' => 2,
	'three' => [
		'four' => 4,
		'five' => 5
	]
];

$second = [
	'two' => 'two',
	'three' => [
		'four' => 'four'
	]
];

Transform::merge($first, $second);

// [
// 	'one' => 1,
// 	'two' => 'two',
// 	'three' => [
// 		'four' => 'four',
// 		'five' => 5
// 	]
// ]
```

### Access

[](#access)

```
use Parkour\Access;
```

[has()](#has), [get()](#get), [set()](#set), [update()](#update).

#### has()

[](#has)

```
$data = [
	'a' => 'foo',
	'b' => [
		'c' => 'bar'
	]
];

Access::has($data, 'b.c'); // true
Access::has($data, ['b', 'c']); // true
```

#### get()

[](#get)

```
$data = [
	'a' => 'foo',
	'b' => [
		'c' => 'bar'
	]
];

Access::get($data, 'a'); // 'foo'
Access::get($data, 'b.c'); // 'bar'
Access::get($data, ['b', 'c']); // 'bar'
```

#### set()

[](#set)

```
$data = [
	'a' => 'foo',
	'b' => [
		'c' => 'bar'
	]
];

$data = Access::set($data, 'a', 'a');
$data = Access::set($data, 'b.c', 'c');
$data = Access::set($data, ['b', 'd'], 'd');

// [
// 	'a' => 'a',
// 	'b' => [
// 		'c' => 'c',
// 		'd' => 'd'
// 	]
// ]
```

#### update()

[](#update)

```
$data = [
	'a' => 'foo',
	'b' => [
		'c' => 'bar'
	]
];

$data = Access::update($data, 'a', function($value) {
	return strtoupper($value);
});

$data = Access::update($data, 'b.c', function($value) {
	return $value . $value;
});

$data = Access::update($data, ['b', 'd'], 'd');

// [
// 	'a' => 'FOO',
// 	'b' => [
// 		'c' => 'barbar'
// 	]
// ]
```

Functors
--------

[](#functors)

`Add`, `AlwaysFalse`, `AlwaysTrue`, `Cunjunct`, `Disjunct`, `Divide`, `Equal`, `Greater`, `GreaterOrEqual`, `Identical`, `Identity`, `Lower`, `LowerOrEqual`, `Multiply`, `NotEqual`, `NotIdentical`, `Substract`.

The vast majority of these functors can be used in two different ways.

Without any configuration:

```
$Add = new Parkour\Functor\Add();
Traverse::reduce([10, 20], $Add, 0);

// is equivalent to:
Traverse::reduce([10, 20], function($memo, $value) {
	return $memo + $value;
}, 0);
```

Or with a fixed parameter:

```
$Add = new Parkour\Functor\Add(5);
Traverse::map([10, 20], $Add, 0);

// is equivalent to:
Traverse::map([10, 20], function($value) {
	return $value + 5;
}, 0);
```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~27 days

Total

3

Last Release

3927d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2738851?v=4)[Fatih GÜRSOY](/maintainers/fg)[@fg](https://github.com/fg)

---

Top Contributors

[![felixgirault](https://avatars.githubusercontent.com/u/1544510?v=4)](https://github.com/felixgirault "felixgirault (74 commits)")[![mattjmattj](https://avatars.githubusercontent.com/u/1842012?v=4)](https://github.com/mattjmattj "mattjmattj (10 commits)")[![manuhabitela](https://avatars.githubusercontent.com/u/221253?v=4)](https://github.com/manuhabitela "manuhabitela (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

arraymanipulationtraversing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fg-parkour/health.svg)

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

###  Alternatives

[doctrine/inflector

PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.

11.3k900.4M877](/packages/doctrine-inflector)[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k430.2M1.4k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k317.3M3.2k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

565335.0M36](/packages/league-config)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4915.7M18](/packages/voku-arrayy)

PHPackages © 2026

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