PHPackages                             p1ratrulezzz/lazyaccess - 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. p1ratrulezzz/lazyaccess

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

p1ratrulezzz/lazyaccess
=======================

Provides LazyAccess posiblity to array elements

2.0.3(5y ago)373[1 PRs](https://github.com/p1ratrulezzz/LazyAccess-to-PHP-arrays/pulls)MITPHPPHP &gt;=5.3.2

Since Apr 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/p1ratrulezzz/LazyAccess-to-PHP-arrays)[ Packagist](https://packagist.org/packages/p1ratrulezzz/lazyaccess)[ RSS](/packages/p1ratrulezzz-lazyaccess/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)DependenciesVersions (6)Used By (0)

LazyAccess
==========

[](#lazyaccess)

[![Latest Stable Version](https://camo.githubusercontent.com/eb8afd391d9ee2d09d11ecd465e8d39e845bcd153eade61f8ddc8ea033613324/68747470733a2f2f706f7365722e707567782e6f72672f703172617472756c657a7a7a2f6c617a796163636573732f762f737461626c65)](https://packagist.org/packages/p1ratrulezzz/lazyaccess)[![Latest Unstable Version](https://camo.githubusercontent.com/f515fa6efe3bd0cfcf1ef186a0471e7158a3531f082ce3e281012d4409df49ca/68747470733a2f2f706f7365722e707567782e6f72672f703172617472756c657a7a7a2f6c617a796163636573732f762f756e737461626c65)](https://packagist.org/packages/p1ratrulezzz/lazyaccess)[![Total Downloads](https://camo.githubusercontent.com/68caf46235e007748edf7ace4f5c8ebcfde02ff72007435a89ff5d590c8ec0fc/68747470733a2f2f706f7365722e707567782e6f72672f703172617472756c657a7a7a2f6c617a796163636573732f646f776e6c6f616473)](https://packagist.org/packages/p1ratrulezzz/lazyaccess)[![License](https://camo.githubusercontent.com/3e27767ef675a3485bff00b268437bb24b81996fc63bad1195e7b5e45372f12c/68747470733a2f2f706f7365722e707567782e6f72672f703172617472756c657a7a7a2f6c617a796163636573732f6c6963656e7365)](https://packagist.org/packages/p1ratrulezzz/lazyaccess)

LazyAccess is a wrapper around any arrays. Provides easy way of getting it's values or get a default value instead.

Replaces stupid long constructions like

```
isset($var) ? $var : NULL.
```

Installation
============

[](#installation)

Using composer
--------------

[](#using-composer)

Update your composer.json with following:

```
    require: {
        "p1ratrulezzz/lazyaccess": "master"
    }
```

and run

```
composer install
```

or (recommended)

```
composer require p1ratrulezzz/lazyaccess master
```

Second method will allow you to install this package without manual changes in composer.lock file.

Manual installation
-------------------

[](#manual-installation)

```
git clone --branch master https://github.com/p1ratrulezzz/LazyAccess-to-PHP-arrays.git lazyaccess
```

Then in PHP code include the files

```
require_once 'lazyaccess/src/LazyAccess.php';
require_once 'lazyaccess/src/LazyAccessTyped.php';
```

Description
===========

[](#description)

For example: usual PHP code is

```
$somevar = isset($array[$key]['key2'][0]) ? $array[$key]['key2'][0] : 'some_default_value';
```

This code is long and duplicates same things. With LazyAccess same code will be

```
$wrapper = new LazyAccessTyped($array); //Define it once somewhere in your code
$somevar = $array[$key]->key2[0]->value('some_default_value');
//or
$somevar = $array[$key]['key2'][0]->value('some_default_value'); //the same as the above
//or
$somevar = $array->$key->key2->0->value('some_default_value'); //the same as the above
// Also there are some wrappers with types: asString(), asInteger(), asDouble()
$somevar = $array->{$key}->key2->0->asString('some_default_value');
$somevar = $array->{$key}->key2->0->asInteger(0); // It will perform intval() operation before returning, so you can be sure that there will be an integer value.
// asDouble() also will replace comma "," to a point ".", for example value 1,93 will be converted to 1.93
$floating_point_value = new LazyAccessTyped(['test_float' => ['inner' => '1,93']])->test_float->inner->asDouble(0); // Will return 1.93
```

It provides ability to use array operator ("\[\]") or object operator ("-&gt;") to access nesting array elements!

Note
====

[](#note)

There are two classes LazyAccess and LazyAccessTyped. LazyAccessTyped provides ability to use converters such as asFloat(), asInteger() and etc.

Please, do not use LazyAccess, cause it can behave unpredictible with it's return value. LazyAccessTyped is much better and safer.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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

Total

5

Last Release

2093d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5019669?v=4)[P1ratRuleZZZ](/maintainers/p1ratrulezzz)[@p1ratrulezzz](https://github.com/p1ratrulezzz)

---

Top Contributors

[![p1ratrulezzz](https://avatars.githubusercontent.com/u/5019669?v=4)](https://github.com/p1ratrulezzz "p1ratrulezzz (23 commits)")

### Embed Badge

![Health badge](/badges/p1ratrulezzz-lazyaccess/health.svg)

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

PHPackages © 2026

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