PHPackages                             maike/iterable - 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. maike/iterable

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

maike/iterable
==============

An abstract class that gives you the power of making your class iterable

1.1.0(5y ago)13301MITPHPPHP &gt;=7.4

Since Sep 1Pushed 5y ago2 watchersCompare

[ Source](https://github.com/maikenegreiros/Iterable)[ Packagist](https://packagist.org/packages/maike/iterable)[ RSS](/packages/maike-iterable/feed)WikiDiscussions master Synced 1w ago

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

Iterable\\Iterator
==================

[](#iterableiterator)

[![](https://camo.githubusercontent.com/35e4231a4f43b3ddfe4143f3c4a30751ec6647c3256e3429d62d9e3b3a7680d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61696b652f6974657261626c653f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/35e4231a4f43b3ddfe4143f3c4a30751ec6647c3256e3429d62d9e3b3a7680d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61696b652f6974657261626c653f7374796c653d666f722d7468652d6261646765)[![](https://camo.githubusercontent.com/beff170511a8cadbe9b3d1565155a998e284f34e3ce251df9a05aef1814224b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d61696b652f6974657261626c653f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/beff170511a8cadbe9b3d1565155a998e284f34e3ce251df9a05aef1814224b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d61696b652f6974657261626c653f7374796c653d666f722d7468652d6261646765)[![](https://camo.githubusercontent.com/7e49a8740f36e418e096f925cd3294bfb4e2cb9511fa68d946b874bd3a5cc780/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d61696b652f6974657261626c653f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/7e49a8740f36e418e096f925cd3294bfb4e2cb9511fa68d946b874bd3a5cc780/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d61696b652f6974657261626c653f7374796c653d666f722d7468652d6261646765)

In other languages, like Java, you can use Collections that allows only one type. In TypeScript, for example we can do the following:

```
public getItems(): Array
{
  return this.items;
}
```

Unfortunatelly, PHP doesn't have this kind of thing, that's why I created this abstract class

Installing
----------

[](#installing)

This package is installed via composer:

```
composer require maike/iterable
```

Usage
-----

[](#usage)

In order to achieve a Collection that allows only one type in PHP, we have to create a class. In the following example, I'm creating a Collection Class extending the `Iterable\Iterator` abstract class

### Creating a Collection Class

[](#creating-a-collection-class)

```
use Iterable\Iterator;

class DateTimeCollection extends Iterator {
  public function __construct(\DateTime ...$items)
  {
    parent::__construct($items);
  }
}
```

With the above code we achieved two things:

1. We have a collection that only allows `DateTime` Objects.
2. We can iterate over our Collection as we do in an array. See the following example:

```
$datesCollection = new DateTimeCollection(
  new \DateTime,
  new \DateTime,
  new \DateTime,
);

foreach ($datesCollection as $key => $date) {
  // Do whatever you want
}
```

Contributing
------------

[](#contributing)

### Run build

[](#run-build)

```
make build
```

### Run tests

[](#run-tests)

```
make tests
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

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

Total

2

Last Release

2084d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31582481?v=4)[Maike Negreiros](/maintainers/maikenegreiros)[@maikenegreiros](https://github.com/maikenegreiros)

---

Top Contributors

[![maikenegreiros](https://avatars.githubusercontent.com/u/31582481?v=4)](https://github.com/maikenegreiros "maikenegreiros (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maike-iterable/health.svg)

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

###  Alternatives

[spatie/laravel-livewire-onboard

A Laravel package to help track user onboarding steps

8171.1k](/packages/spatie-laravel-livewire-onboard)[msamgan/laravel-env-keys-checker

check if all the keys are available in all the .env files.

8035.5k1](/packages/msamgan-laravel-env-keys-checker)

PHPackages © 2026

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