PHPackages                             bvtterfly/cycler - 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. bvtterfly/cycler

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

bvtterfly/cycler
================

An easy way to rotate through several values is to use cycler

1.0.0(4y ago)105[2 PRs](https://github.com/bvtterfly/cycler/pulls)MITPHPPHP ^8.0

Since Apr 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bvtterfly/cycler)[ Packagist](https://packagist.org/packages/bvtterfly/cycler)[ Docs](https://github.com/bvtterfly/cycler)[ GitHub Sponsors](https://github.com/bvtterfly)[ RSS](/packages/bvtterfly-cycler/feed)WikiDiscussions main Synced 1mo ago

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

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨

I no longer use PHP and cannot justify the time needed to maintain this package. That's why I have chosen to abandon it. Feel free to fork my code and maintain your own copy.

Cycler : An easy way to rotate through several values
=====================================================

[](#cycler--an-easy-way-to-rotate-through-several-values)

[![Latest Version on Packagist](https://camo.githubusercontent.com/848d4db229d907759322498fe2a00911fc434803d928d9acb6a6b7836bd47fce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627674746572666c792f6379636c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bvtterfly/cycler)[![Tests](https://github.com/bvtterfly/cycler/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/bvtterfly/cycler/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/6f450b60ad3bf598276912e0a6afcd2cd0b2016caf8e72bea5ec546a491e127f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f627674746572666c792f6379636c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bvtterfly/cycler)

An easy way to rotate through several values is to use cycler, which takes any number of arguments and cycles through them.

```
$cycle = cycler('odd', 'even');
$numbers = [1,2,3,4,5,6];
foreach ($numbers as $number) {
    echo "{$number} is {$cycle->next()}";
}
// prints 1 is odd 2 is even 3 is odd 4 is even 5 is odd 6 is even
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require bvtterfly/cycler
```

Usage
-----

[](#usage)

Let's say we want to display ads every three posts on our blog's home page. Then we can use `cycler`:

```
$adsCycle = cycler(false, false, true);
foreach ($posts as $post) {
    // show post
    if ($adsCycle->next()) {
        // show add
    }
}
```

You can access the current item using the `current` method (in the above example, `$adsCycle->current()`)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Ari](https://github.com/bvtterfly)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

1495d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/99682351?v=4)[Λгi](/maintainers/bvtterfly)[@bvtterfly](https://github.com/bvtterfly)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")[![bvtterfly](https://avatars.githubusercontent.com/u/99682351?v=4)](https://github.com/bvtterfly "bvtterfly (4 commits)")

---

Tags

bvtterflycycler

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/bvtterfly-cycler/health.svg)

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

###  Alternatives

[kenjis/ci3-to-4-upgrade-helper

Help upgrade from CodeIgniter3 to CodeIgniter4

695.9k](/packages/kenjis-ci3-to-4-upgrade-helper)[anerg2046/helper

some helper libaray function

2313.9k2](/packages/anerg2046-helper)[shrink0r/monatic

Fiddling with the monad concept in php

245.3k2](/packages/shrink0r-monatic)[purplespider/mypswd-tweaks

Custom SilverStripe tweaks to keep things tidy.

181.4k](/packages/purplespider-mypswd-tweaks)[innmind/git

Git abstraction

141.4k1](/packages/innmind-git)[dvizh/yii2-field

yii2-field add fields to your model

111.7k](/packages/dvizh-yii2-field)

PHPackages © 2026

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