PHPackages                             yrizos/bucket - 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. yrizos/bucket

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

yrizos/bucket
=============

A set of basic containers, and a more complicated one with onSet and onGet hooks.

0.2.0(11y ago)695MITPHPPHP &gt;=5.4.0

Since Mar 1Pushed 11y ago1 watchersCompare

[ Source](https://github.com/yrizos/bucket)[ Packagist](https://packagist.org/packages/yrizos/bucket)[ Docs](https://github.com/yrizos/bucket)[ RSS](/packages/yrizos-bucket/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

Bucket
======

[](#bucket)

Bucket is a collection of container objects.

### Basic containers

[](#basic-containers)

There are four basic container traits:

- ContainerTrait: implements \\Countable, \\IteratorAggregate
- ArrayContainerTrait: adds \\ArrayAccess to the mix
- MagicContainerTrait: if you prefer magic getter &amp; setters to \\ArrayAccess
- MagicArrayContainerTrait: the name is revealing, isn't it?

You can either attach the traits to your own classes, or use the concrete classes provided. Here's a quick example:

```
class MyContainer implements Bucket\Container\MagicArrayContainerInterface
{
    use Bucket\Container\MagicArrayContainerTrait;
}

$myContainer        = new MyContainer();
$myContainer->label = "hello world";

echo $myContainer["label"];
```

### Bucket

[](#bucket-1)

Bucket is a bit more interesting, adding hooks to the mix.

```
$bucket = new Bucket\Bucket();

$bucket->onGet("name", function ($value) {
    return trim($value);
});

$bucket->onSet("email", function ($value) {

    if (!filter_var($value, FILTER_VALIDATE_EMAIL))
        throw new  \InvalidArgumentException();

    return filter_var($value, FILTER_SANITIZE_EMAIL);
});

$bucket->name = "    Yannis    ";
var_dump($bucket->name); // string 'Yannis' (length=6)

$bucket->email = 42; // will fail
```

### Setup

[](#setup)

```
require: "yrizos/bucket": "dev-master"

```

[![Build Status](https://camo.githubusercontent.com/90809cfe17df9011e2f08b2393841bc16a9a1a1d7f52db4b231b1597dff35335/68747470733a2f2f7472617669732d63692e6f72672f7972697a6f732f6275636b65742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/yrizos/bucket)

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

4365d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.3.0

0.2.0PHP &gt;=5.4.0

### Community

Maintainers

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

---

Top Contributors

[![yrizos](https://avatars.githubusercontent.com/u/282929?v=4)](https://github.com/yrizos "yrizos (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yrizos-bucket/health.svg)

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

###  Alternatives

[nystudio107/eagerbeaver

Allows you to eager load elements from auto-injected Entry elements on demand from your templates.

251.5k](/packages/nystudio107-eagerbeaver)

PHPackages © 2026

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