PHPackages                             dbx12/safe-array-read - 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. dbx12/safe-array-read

Abandoned → use native null-coalescing operatorArchivedLibrary[Utility &amp; Helpers](/categories/utility)

dbx12/safe-array-read
=====================

Prevent these undefined index warnings by using a safe array read.

1.0(7y ago)02MITPHPPHP ^7.1CI failing

Since Dec 25Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/DBX12/safe-array-read)[ Packagist](https://packagist.org/packages/dbx12/safe-array-read)[ RSS](/packages/dbx12-safe-array-read/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

This project is archived.
=========================

[](#this-project-is-archived)

Use the null-coalescing operator (`$array['key'] ?? 'fallback'`) instead. This project is no longer maintained and no guarantees for security and stability are given anymore.

Safe array reading
==================

[](#safe-array-reading)

Normally, this should not be something you need, because you don't know how to do it. If you don't know how to read safely from an array I suggest to read the code of this "library". I put that in quotes intentionally, as a class with one static function is hardly a library.

However, I created this repository for the sake of simplicity. In most of my projects, I have a file somewhere called "utilities.php" and this file holds such helper methods; over time, more methods are added as they not exactly fit into the controller or the model of the MVC pattern. To prevent this chaos, the method is added via dependency.

Normally I hate libraries like the "is-odd" library from npm but I hope, community and my future self forgive me.

About the version constraint
----------------------------

[](#about-the-version-constraint)

I only tested it with phpunit 7.5.1 which runs on 7.0 or higher so I only assure it works on this configuration. Older versions should be still supported.

Usage
-----

[](#usage)

I'm not sure why I'm adding this, it's really simple to use:

```
$array = [
    'foo' => 1
];
\dbx12\SafeArrayRead::read('foo', $array, 'baz');
# returns 1
\dbx12\SafeArrayRead::read('bar', $array, 'baz');
# returns baz````
```

(Fun fact: This README file is bigger than the actual source code.)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance54

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

2697d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7dd9e7c6d0c101b23d35ddde728a50a7263b43f2103416c3022cb5f6ca0fa7ab?d=identicon)[DBX12](/maintainers/DBX12)

---

Top Contributors

[![DBX12](https://avatars.githubusercontent.com/u/6484542?v=4)](https://github.com/DBX12 "DBX12 (5 commits)")[![particleflux](https://avatars.githubusercontent.com/u/3686454?v=4)](https://github.com/particleflux "particleflux (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dbx12-safe-array-read/health.svg)

```
[![Health](https://phpackages.com/badges/dbx12-safe-array-read/health.svg)](https://phpackages.com/packages/dbx12-safe-array-read)
```

PHPackages © 2026

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