PHPackages                             uginroot/php-set - 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. uginroot/php-set

ActiveLibrary

uginroot/php-set
================

Php set type

v2.7(5y ago)0321MITPHPPHP ^7.2

Since Jan 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/uginroot/php-set)[ Packagist](https://packagist.org/packages/uginroot/php-set)[ RSS](/packages/uginroot-php-set/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (10)DependenciesVersions (19)Used By (1)

Install
=======

[](#install)

```
composer require uginroot/php-set:^2.6
```

Usage
=====

[](#usage)

```
use Uginroot\PhpSet\SetAbstract;
use Uginroot\PhpSet\Choice;

class Animals extends SetAbstract{
    protected const Other = 0; // Is not considered

    public const Dog = 1;
    public const Cat = 2;
    public const Wolf = 3;
    public const Lion = 4;
}

/** @var Choice $choice */
$choice = Animals::getChoice();
$choice->getNames(); // ['Dog', 'Cat', 'Wolf', 'Lion']
$choice->getValues(); // [1, 2, 3, 4]
$choice->getName(1); // 'Dog'
$choice->getValue('Dog'); // 1
$choice->findNames(1, 3); // ['Dog', 'Wolf']
$choice->findValues('Dog', 'Wolf'); // [1, 3]
$choice->extractorValues(1, 3); // [1, 3]
$choice->extractorNames('Dog', 'Wolf'); // ['Dog', 'Wolf']

$animalsPets = Animals::constructorFromValues([Animals::Dog, Animals::Cat]);
$animalsPetsNames = Animals::constructorFromNames(['Dog', 'Cat']);

// Compare
$animalsPets->in(Animals::Dog);                  // true
$animalsPets->in(Animals::Dog, Animals::Wolf);   // true

$animalsPets->is(Animals::Dog);                  // true
$animalsPets->is(Animals::Dog, Animals::Wolf);   // false

$animalsPets->equal(Animals::Dog, Animals::Cat); // true
$animalsPets->equal(Animals::Cat);               // false
$animalsPets->equal($animalsPetsNames);          // true

Animals::equals(
    Animals::constructorFromValues([Animals::Wolf]),
    Animals::constructorFromValues([Animals::Wolf])
); // true

// Current names|values
$animalsPets->getValues(); // [1, 2]
$animalsPets->getNames();  // ['Dog', 'Cat']

// Create add return modified object
$animalsPets->addValues(Animals::Wolf);
$animalsPets->addNames('Lion');

$animalsPets->removeValues(Animals::Wolf);
$animalsPets->removeNames('Lion');

$animalsPets->setValues(Animals::Wolf, Animals::Lion);
$animalsPets->setNames('Wolf', 'Lion');
```

Exceptions
==========

[](#exceptions)

```
use Uginroot\PhpSet\SetAbstract;
use Uginroot\PhpSet\Exception\DuplicateValueException;
use Uginroot\PhpSet\Exception\IncorrectValueException;
use Uginroot\PhpSet\Exception\IncorrectNameException;
use Uginroot\PhpSet\Choice;

class Animals extends SetAbstract{
    public const Dog = 1;
    public const Cat = 2;
}

/** @var Choice $choice */
$choice = Animals::getChoice();

try{ $choice->getName(3); } catch (IncorrectValueException $e){}
try{ $choice->getValue('Wolf'); } catch (IncorrectNameException $e){}

class Buttons extends SetAbstract{
    public const Cancel = 1;
    public const Accept = 1;
    public const Reject = 1;
}

try{ Buttons::getChoice(); } catch (DuplicateValueException $e){}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

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

Recently: every ~14 days

Total

18

Last Release

2174d ago

Major Versions

v1.9 → v2.02020-02-25

PHP version history (2 changes)v1.0PHP ^7.4

v2.2PHP ^7.2

### Community

Maintainers

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

---

Top Contributors

[![uginroot](https://avatars.githubusercontent.com/u/2391460?v=4)](https://github.com/uginroot "uginroot (38 commits)")

---

Tags

phptypeset

### Embed Badge

![Health badge](/badges/uginroot-php-set/health.svg)

```
[![Health](https://phpackages.com/badges/uginroot-php-set/health.svg)](https://phpackages.com/packages/uginroot-php-set)
```

###  Alternatives

[zakirullin/mess

Convenient array-related routine &amp; better type casting

21228.9k2](/packages/zakirullin-mess)[strictus/strictus

Strict Typing for local variables in PHP

1606.9k](/packages/strictus-strictus)[webparking/laravel-type-safe-collection

This package provides type-safe extension of the laravel collection, forcing a single type of object.

378.2k](/packages/webparking-laravel-type-safe-collection)

PHPackages © 2026

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