PHPackages                             collection-interop/stack - 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. collection-interop/stack

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

collection-interop/stack
========================

An interface describing the behaviours of a 'stack' abstract data type (ADT).

v1.0.0(6y ago)01MITPHPPHP ^7.3

Since Aug 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/collection-interop/stack)[ Packagist](https://packagist.org/packages/collection-interop/stack)[ RSS](/packages/collection-interop-stack/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

stack
=====

[](#stack)

An interface describing the behaviours of a 'stack' abstract data type (ADT).

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

[](#installation)

The best way to use these interfaces in your project/library, is via [Composer](https://getcomposer.org/):

```
$ composer require collection-interop/stack

```

Usage
-----

[](#usage)

```
final class DeviceHistory implements \Interop\Collection\Stack
{
    private $commands = [];
    private $type = '';

    public function push(object $item): void
    {
        if (!$this->type) {
            $this->type = get_class($item);
        }

        if (!($item instanceof $this->type)) {
            throw new InvalidArgumentException(
                sprintf('Item must be an instance of %s. Instance of %s was given instead.', $this->type, get_class($item))
            );
        }

        $this->commands[] = $item;
    }

    public function pop(): object
    {
        return array_pop($this->commands);
    }
}

final class Command
{
    public $action;
    public function __construct(string $action) {
        $this->action = $action;
    }
}

final class TurnOffCommand
{
    public $action = 'turn-off';
}

$history = new DeviceHistory();
$history->push(new Command('turn-on'));
//$history->push(new TurnOffCommand());   // uncomment line to verify that only objects of same type can be added
$history->push(new Command('change-channel'));

var_dump($history->pop());  // returns 'change-channel'
var_dump($history->pop());  // returns 'turn-on'
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

2476d ago

### Community

Maintainers

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

---

Top Contributors

[![nbish11](https://avatars.githubusercontent.com/u/1518821?v=4)](https://github.com/nbish11 "nbish11 (6 commits)")

### Embed Badge

![Health badge](/badges/collection-interop-stack/health.svg)

```
[![Health](https://phpackages.com/badges/collection-interop-stack/health.svg)](https://phpackages.com/packages/collection-interop-stack)
```

###  Alternatives

[slince/shipment-tracking

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

291.6k4](/packages/slince-shipment-tracking)

PHPackages © 2026

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