PHPackages                             metator/cart - 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. metator/cart

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

metator/cart
============

Simplest 'cart' class ever written.

1.0.1(12y ago)0204OSL-3.0PHP

Since Jul 6Pushed 12y ago2 watchersCompare

[ Source](https://github.com/metator/cart)[ Packagist](https://packagist.org/packages/metator/cart)[ RSS](/packages/metator-cart/feed)WikiDiscussions master Synced 4w ago

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

[![Coverage Status](https://camo.githubusercontent.com/78eec70b12424b3493867ff2536cfbc4c53aaf0d0ae80b4d4578601f2f818222/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6d657461746f722f636172742f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/metator/cart?branch=master)[![Build Status](https://camo.githubusercontent.com/34961ec36b22b5658d4b78c0aa79784c5ef4fe591d9ffe72a12daf25cecd5d64/68747470733a2f2f7472617669732d63692e6f72672f6d657461746f722f636172742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/metator/cart)

Metator Cart
============

[](#metator-cart)

The simplest shopping cart class ever to exist. For a full stack shopping cart system, check out metator/application.

The cart class class is hopefully very intuitive. It depends on nothing, and assumes nothing except that your items have a unique identifier.

```
use Metator\Cart\Cart;

$cart = new Cart;
$cart->add(5);
$cart->add(5);
$cart->add(5);

echo $cart->quantity(5); // 3
print_r($cart->items()); // array(5)

$cart->remove(5);
echo $cart->quantity(5); // 0
print_r($cart->items()); // array()

$cart->add(5);
$cart->setQuantity(5,500);

echo $cart->quantity(5); // 500

$cart->setQuantity(5,0);
print_r($cart->items()); // array()
```

\##Understanding Identifiers## The value for the ID could be the auto\_increment from your database, a product SKU, or any kind of unique identifier like a hash. For example if a T-Shirt comes in multiple colors but always has the same SKU &amp; ID regardless of color, you could use a hash representing the configured state of that product for the id here.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

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

Total

2

Last Release

4742d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4021306?v=4)[Josh Ribakoff](/maintainers/joshribakoff)[@joshribakoff](https://github.com/joshribakoff)

---

Top Contributors

[![joshribakoff](https://avatars.githubusercontent.com/u/4021306?v=4)](https://github.com/joshribakoff "joshribakoff (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/metator-cart/health.svg)

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k430.2M1.4k](/packages/doctrine-collections)[vyuldashev/nova-money-field

A Laravel Nova field for Money.

73814.0k1](/packages/vyuldashev-nova-money-field)[th3n3rd/cartesian-product

Memory efficient Cartesian Product implementation

13156.8k3](/packages/th3n3rd-cartesian-product)[mercari/composer-diff-plugin

composer plugin to show library version diff at "composer update"

122.7k](/packages/mercari-composer-diff-plugin)

PHPackages © 2026

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