PHPackages                             southcoast/helpers - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. southcoast/helpers

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

southcoast/helpers
==================

A Collection of helper classes for PHP

v1.x-dev(7y ago)21.3kMITPHPPHP &gt;=7.0.0

Since Feb 25Pushed 11mo ago3 watchersCompare

[ Source](https://github.com/cornejong/southcoast-helpers)[ Packagist](https://packagist.org/packages/southcoast/helpers)[ Docs](https://github.com/Seldaek/monolog)[ RSS](/packages/southcoast-helpers/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

SouthCoast | Helpers
====================

[](#southcoast--helpers)

[![Codacy Badge](https://camo.githubusercontent.com/b45e734e060a277fb9dafd9a354cf5f4502fc8a0bbf4fa8992c729c9562728b4/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6430376662376633353132303438366361653061303464613637646438626432)](https://app.codacy.com/app/corne.dejong/southcoast-helpers?utm_source=github.com&utm_medium=referral&utm_content=cornejong/southcoast-helpers&utm_campaign=Badge_Grade_Dashboard)

A Collection of helper classes for PHP

Could be installed via composer:

```
$ composer require southcoast/helpers:dev-master
```

Or by manually downloading the .zip file.

Array Helper
------------

[](#array-helper)

### `ArrayHelper::Map(array $map, array $array): array;`

[](#arrayhelpermaparray-map-array-array-array)

```
$map        array   The mapping
$array      array   The original array where data should come from
Returns     array   The mapped array
```

This method allows you to map an existing array to a new one. It has support for dot notation for use of multidimensional arrays. Both for the 'field' and the mapping keys

Accepted keys in the mapping array:

```
[
    'field' => 'The key to the field from the original $array',
    'alt_field' => 'An alternative key in the original $array for when the primary field is not found or returns null',
    'value' => 'A static value, or mutation of the value, This will over ride the value of the primary field',
    'or' => 'A static value that should be used',
    'add' => 'If the field should be used or not, accepts true or false values'
]
```

Mapping Example:

```
$map = [
    // The Key is the to be used key for the Array
    // The value of 'field' is the value origin
    'New_Name' => ['field' => 'old_name'],

    // Add 'value' to add custom value or value mutation
    'Email' => ['value' => 'Some Other Value'],

    // Add '.' separators for sub objects
    'Email.primary' => ['field' => 'email'],

    // Use '0' for arrays
    'Addresses.0.street' => ['field' => 'address_1_line_1'],

    // Get a value from a multidimensional source
    'isDefault' => ['field' => 'meta.system.default'],

    // Add the 'or' field to supply a value that will used if the value from the original array is not found or null
    'automated' => ['field' => 'system.automated', 'or' => 'nope, not automated']

    // Use the 'add' field to specify if this field should be added
    'someAwesomeField' => ['field' => 'getMyValue', 'add' => false] // Wont be added
    'someAwesomeField' => ['field' => 'getMyValue', 'add' => true] // Will be added

    // Add an alternative field to the mapping if the original field is missing or returned null
    'arbitraryKey' => ['field' => 'getItFromHere', 'alt_field' => 'or_from_here', 'or' => 'a default value']
];
```

Example:

```
$array = [
    'key_1' => 'value_1',
    'key_2' => 'value_2',
    'array' => [
        'a_key_1' => 'a_value_1',
        'a_key_2' => 'a_value_2',
        'a_key_3' => null
    ]
];

$map = [
    'field_one' => ['field' => 'array.a_key_1'],
    'field_two' => ['field' => 'key_1', 'add' => false],
    'field_three' => ['value' => 'new_value'],
    'field_four' => ['field' => 'array.a_key_5', 'alt_field' => 'key_2'],
    'field_five' => 'This Value',
    'array.a_field' => ['field' => 'array.a_key_3', 'or' => 'nope, no value'],
    'array.0' => ['field' => 'array.a_key_2']
];

$result = ArrayHelper::map($map, $array);

$result = [
    /* The key 'field_one' had the value of array['a_key_1'] */
    'field_one' => 'a_value_1',
    /* The key 'field_two' was not added, because 'add' was false */
    /* The key 'field_three' has a custom value */
    'field_three' => 'new_value',
    /* The key 'field_four' now bears the value of 'key_2' because 'array.a_key_5' could not be found */
    'field_four' => 'value_2',
    /* The key 'field_five' also carries a custom value */
    'field_five' => 'This Value',
    /* The key 'array' now contains an array */
    'array' => [
        /* With a key 'a_field' with the 'or' value because 'array.a_key_3' has a null value */
        'a_field' => 'nope, no value',
        /* Also a numeric key was added with the value of 'array.a_key_2' */
        0 => 'a_value_2'
    ]
]
```

Environment
-----------

[](#environment)

Create a file called 'sc.env'. This file should contain the following structure:

```
{
    "dev": true,
    "machine": "",
    "...": "Any other parameters you'd like to add to your environment"
}
```

In your main php file load the env file.

```
$path_to_env = './sc.env';
Env::load($path_to_env);
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99% 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

2

Last Release

2633d ago

### Community

Maintainers

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

---

Top Contributors

[![cornejong](https://avatars.githubusercontent.com/u/12799240?v=4)](https://github.com/cornejong "cornejong (98 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")

---

Tags

logjsonloggingvalidationhelperarrayhelpersobjectidentifierenvEnvoiroment

### Embed Badge

![Health badge](/badges/southcoast-helpers/health.svg)

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

###  Alternatives

[jbzoo/utils

Collection of PHP functions, mini classes and snippets for everyday developer's routine life.

8321.5M36](/packages/jbzoo-utils)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

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