PHPackages                             dev-toolbelt/enums - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dev-toolbelt/enums

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dev-toolbelt/enums
==================

A shared set of open-source enums for frequently used domains, helping reduce duplication and improve consistency across software projects.

1.0.0(3mo ago)15363MITPHPPHP ^8.1CI passing

Since Feb 1Pushed 3mo agoCompare

[ Source](https://github.com/Dev-Toolbelt/enums)[ Packagist](https://packagist.org/packages/dev-toolbelt/enums)[ RSS](/packages/dev-toolbelt-enums/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (3)

Dev-Toolbelt Enums
==================

[](#dev-toolbelt-enums)

[![CI](https://github.com/dev-toolbelt/enums/actions/workflows/ci.yml/badge.svg)](https://github.com/dev-toolbelt/enums/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/0b7361a1aa695006aa9f59e1ffe4203f9a0149982d342607a6bad0a5829ba553/68747470733a2f2f636f6465636f762e696f2f67682f6465762d746f6f6c62656c742f656e756d732f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/dev-toolbelt/enums)[![Latest Stable Version](https://camo.githubusercontent.com/c3966d16245fcb8042f2c231ea4bbdcdcd98511734108b5eb041e2f7687e5a17/68747470733a2f2f706f7365722e707567782e6f72672f6465762d746f6f6c62656c742f656e756d732f762f737461626c65)](https://packagist.org/packages/dev-toolbelt/enums)[![Total Downloads](https://camo.githubusercontent.com/8392082bec9801140f204643819410df6197ae9245a7fbbe4e97fc6be37e306e/68747470733a2f2f706f7365722e707567782e6f72672f6465762d746f6f6c62656c742f656e756d732f646f776e6c6f616473)](https://packagist.org/packages/dev-toolbelt/enums)[![License](https://camo.githubusercontent.com/b70466a4be10c579572adb1766f8cab4383715605fea55f1c2f598d2245abf7b/68747470733a2f2f706f7365722e707567782e6f72672f6465762d746f6f6c62656c742f656e756d732f6c6963656e7365)](https://packagist.org/packages/dev-toolbelt/enums)[![PHP Version](https://camo.githubusercontent.com/5670f7f36101e1f4cec507c344c9bb30634c4ce5ec77f5ca0206a26c0479f269/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465762d746f6f6c62656c742f656e756d73)](https://packagist.org/packages/dev-toolbelt/enums)

A comprehensive PHP library providing **type-safe enum classes** for commonly used domains. Stop reinventing the wheel - use battle-tested, well-documented enums across all your PHP projects.

Why Use This Library?
---------------------

[](#why-use-this-library)

- **Framework Agnostic** - Works with Laravel, Symfony, Slim, CodeIgniter, or any PHP 8.1+ application
- **Type Safety** - Leverage PHP 8.1 native enums for compile-time type checking
- **Consistent API** - All enums follow the same patterns with `fullName()`, `toArray()`, and domain-specific helper methods
- **Internationalization Ready** - Brazilian Portuguese translations included via `fullNamePtBr()` methods
- **Well Tested** - 247 tests with 1,669 assertions ensuring reliability
- **Zero Dependencies** - No external packages required

Requirements
------------

[](#requirements)

- **PHP 8.1** or higher

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

[](#installation)

```
composer require dev-toolbelt/enums
```

Available Enums
---------------

[](#available-enums)

The library organizes enums into logical namespaces:

NamespaceEnumsDescription`Security`AlgorithmJWT/cryptographic algorithms (HS256, RS256, ES256, etc.)`Brazil`BrazilianState, BrazilianDocumentType, BrazilianBankCodeBrazilian-specific data`Http`HttpMethod, HttpStatusCode, MimeTypeHTTP protocol enums`Locale`Country, Currency, Language, TimezoneInternationalization`Calendar`Month, DayOfWeekDate and time`Personal`Gender, ContactTypePersonal information`Measurement`TemperatureUnits of measurementUsage Examples
--------------

[](#usage-examples)

### HTTP Status Codes

[](#http-status-codes)

```
use DevToolbelt\Enums\Http\HttpStatusCode;

$status = HttpStatusCode::NOT_FOUND;

echo $status->value;          // 404
echo $status->reasonPhrase(); // "Not Found"

// Category checks
$status->isClientError(); // true
$status->isServerError(); // false
$status->isError();       // true
$status->isSuccess();     // false
```

### HTTP Methods

[](#http-methods)

```
use DevToolbelt\Enums\Http\HttpMethod;

$method = HttpMethod::POST;

echo $method->value;       // "POST"
$method->isSafe();         // false (modifies resources)
$method->isIdempotent();   // false
$method->allowsBody();     // true
```

### Countries &amp; Currencies

[](#countries--currencies)

```
use DevToolbelt\Enums\Locale\Country;
use DevToolbelt\Enums\Locale\Currency;

$country = Country::BR;
echo $country->label(); // "Brazil"
echo $country->alpha3();   // "BRA"

$currency = Currency::BRL;
echo $currency->label();     // "Brazilian Real"
echo $currency->symbol();       // "R$"
echo $currency->decimalPlaces(); // 2
```

### Languages

[](#languages)

```
use DevToolbelt\Enums\Locale\Language;

$lang = Language::PT_BR;

echo $lang->label();    // "Portuguese (Brazil)"
echo $lang->nativeName();  // "Português"
echo $lang->direction();   // "ltr"
echo $lang->baseLanguage(); // "pt"
echo $lang->region();      // "BR"

// Right-to-left detection
Language::AR->isRightToLeft(); // true
Language::EN->isRightToLeft(); // false
```

### Timezones

[](#timezones)

```
use DevToolbelt\Enums\Locale\Timezone;

$tz = Timezone::AMERICA_SAO_PAULO;

echo $tz->value;              // "America/Sao_Paulo"
echo $tz->getUtcOffsetString(); // "-03:00"

// Convert to DateTimeZone
$dateTimeZone = $tz->toDateTimeZone();
```

### Brazilian States

[](#brazilian-states)

```
use DevToolbelt\Enums\Brazil\BrazilianState;

$state = BrazilianState::SP;

echo $state->value;    // "SP"
echo $state->label(); // "São Paulo"
echo $state->label(toUppercase: true); // "SÃO PAULO"

// Get all states as array
$states = BrazilianState::toArray(); // ['AC' => 'AC', 'AL' => 'AL', ...]
$statesWithNames = BrazilianState::toArrayWithFullNames(); // ['AC' => 'Acre', ...]
```

### Brazilian Documents

[](#brazilian-documents)

```
use DevToolbelt\Enums\Brazil\BrazilianDocumentType;

$doc = BrazilianDocumentType::CPF;

echo $doc->label(); // "Cadastro de Pessoa Física"
echo $doc->mask();     // "###.###.###-##"
echo $doc->length();   // 11

// Document type checks
$doc->isPersonalDocument();     // true
$doc->isProfessionalDocument(); // false
$doc->isCertificate();          // false
```

### Brazilian Banks

[](#brazilian-banks)

```
use DevToolbelt\Enums\Brazil\BrazilianBankCode;

$bank = BrazilianBankCode::NUBANK;

echo $bank->value;      // "260"
echo $bank->label(); // "Nu Pagamentos S.A. (Nubank)"
echo $bank->shortName(); // "Nubank"
echo $bank->ispb();     // "18236120"
```

### Month &amp; Day of Week

[](#month--day-of-week)

```
use DevToolbelt\Enums\Calendar\Month;
use DevToolbelt\Enums\Calendar\DayOfWeek;

$month = Month::FEBRUARY;
echo $month->label();      // "February"
echo $month->fullNamePtBr();  // "Fevereiro"
echo $month->shortName();     // "Feb"
echo $month->daysCount(2024); // 29 (leap year)
echo $month->quarter();       // 1
$month->next();               // Month::MARCH
$month->previous();           // Month::JANUARY

$day = DayOfWeek::SATURDAY;
echo $day->label();     // "Saturday"
echo $day->fullNamePtBr(); // "Sábado"
$day->isWeekend();         // true
$day->isWeekday();         // false
$day->isoValue();          // 6 (ISO-8601)

// Get collections
DayOfWeek::weekdays(); // [MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY]
DayOfWeek::weekend();  // [SATURDAY, SUNDAY]
```

### Gender &amp; Contact Types

[](#gender--contact-types)

```
use DevToolbelt\Enums\Personal\Gender;
use DevToolbelt\Enums\Personal\ContactType;

$gender = Gender::FEMALE;
echo $gender->label();     // "Female"
echo $gender->fullNamePtBr(); // "Feminino"
echo $gender->pronoun();      // "she/her"
echo $gender->pronounPtBr();  // "ela/dela"

$contact = ContactType::WHATSAPP;
echo $contact->label();  // "WhatsApp"
echo $contact->icon();      // "whatsapp"
echo $contact->baseUrl();   // "https://wa.me/"
echo $contact->buildUrl('+5511999998888'); // "https://wa.me/5511999998888"

$contact->isPhone();         // true
$contact->isMessenger();     // true
$contact->isSocialNetwork(); // false
```

### Temperature Conversion

[](#temperature-conversion)

```
use DevToolbelt\Enums\Measurement\Temperature;

$temp = Temperature::CELSIUS;

echo $temp->symbol(); // "°C"

// Convert between units
$fahrenheit = $temp->convertTo(100, Temperature::FAHRENHEIT); // 212.0
$kelvin = $temp->convertTo(0, Temperature::KELVIN);           // 273.15

// Format output
echo $temp->format(25.5); // "25.50 °C"

// Reference points
$temp->freezingPointOfWater(); // 0.0
$temp->boilingPointOfWater();  // 100.0
$temp->absoluteZero();         // -273.15

// Unit classification
$temp->isMetric();   // true
$temp->isImperial(); // false
$temp->isAbsolute(); // false (Kelvin is absolute)
```

### MIME Types

[](#mime-types)

```
use DevToolbelt\Enums\Http\MimeType;

$mime = MimeType::APPLICATION_JSON;

echo $mime->value; // "application/json"

// Type checks
$mime->isApplication(); // true
$mime->isText();        // false
$mime->isImage();       // false
$mime->isMedia();       // false (images, audio, video)

// Get file extensions
MimeType::IMAGE_JPEG->extensions(); // ['jpg', 'jpeg']
MimeType::TEXT_HTML->extensions();  // ['html', 'htm']
```

### Cryptographic Algorithms

[](#cryptographic-algorithms)

```
use DevToolbelt\Enums\Security\Algorithm;

$algo = Algorithm::RS256;

echo $algo->value; // "RS256"

$algo->isSymmetric();  // false
$algo->isAsymmetric(); // true
$algo->isRSA();        // true
$algo->isECDSA();      // false
```

Building Select Dropdowns
-------------------------

[](#building-select-dropdowns)

All enums provide `toArray()` methods perfect for HTML select elements:

```
use DevToolbelt\Enums\Brazil\BrazilianState;

// For Blade/Twig templates
$states = BrazilianState::toArrayWithFullNames();

// Result: ['AC' => 'Acre', 'AL' => 'Alagoas', 'AM' => 'Amazonas', ...]
```

```

    @foreach($states as $uf => $name)
        {{ $name }}
    @endforeach

```

Framework Integration
---------------------

[](#framework-integration)

### Laravel

[](#laravel)

```
// In a Form Request
use DevToolbelt\Enums\Brazil\BrazilianState;
use Illuminate\Validation\Rule;

public function rules(): array
{
    return [
        'state' => ['required', Rule::enum(BrazilianState::class)],
    ];
}

// In an Eloquent Model
use DevToolbelt\Enums\Http\HttpStatusCode;

protected $casts = [
    'status' => HttpStatusCode::class,
];
```

### Symfony

[](#symfony)

```
// In a Doctrine Entity
use DevToolbelt\Enums\Locale\Currency;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class Product
{
    #[ORM\Column(type: 'string', enumType: Currency::class)]
    private Currency $currency;
}
```

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Run with coverage
composer test:coverage

# Run specific test file
vendor/bin/phpunit --configuration tests/phpunit.xml tests/Unit/Http/HttpStatusCodeTest.php

# Static analysis
composer phpstan

# Code style check
composer phpcs

# Fix code style
composer phpcs:fix
```

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

Please make sure to update tests as appropriate and follow PSR-12 coding standards.

### Code Quality Requirements

[](#code-quality-requirements)

CheckToolRequirementTestsPHPUnitAll tests must passCoveragePCOVMinimum **85%** coverageCode StylePHP CodeSnifferPSR-12 compliantStatic AnalysisPHPStanLevel 6, no errors### Pull Request Guidelines

[](#pull-request-guidelines)

Before submitting a PR, ensure:

1. **All tests pass:** `composer test`
2. **Coverage is at least 85%:** `composer test:coverage`
3. **Code style is correct:** `composer phpcs`
4. **No static analysis errors:** `composer phpstan`

> **Important:** Pull requests with coverage below 85% will be automatically blocked by CI.

### Coverage Report

[](#coverage-report)

- **Dashboard:** [Codecov](https://codecov.io/gh/dev-toolbelt/enums)
- **HTML Report:** [GitHub Pages](https://dev-toolbelt.github.io/enums/)

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Credits
-------

[](#credits)

- [Kilderson Sena](https://github.com/dersonsena)
- [All Contributors](../../contributors)

---

Made with ❤️ by [Dev-Toolbelt](https://github.com/Dev-Toolbelt)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance80

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity43

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

106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61bcbe92662af44dfdd25b210c73e52956e381536edb62ddfae95810e3333e31?d=identicon)[astrotechdevs](/maintainers/astrotechdevs)

---

Top Contributors

[![dersonsena](https://avatars.githubusercontent.com/u/9482515?v=4)](https://github.com/dersonsena "dersonsena (7 commits)")

---

Tags

algorithmbacked-enumenumsphp-enumtimezonejwtcryptographyAlgorithmtimezoneenumsbacked-enumphp-enums

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dev-toolbelt-enums/health.svg)

```
[![Health](https://phpackages.com/badges/dev-toolbelt-enums/health.svg)](https://phpackages.com/packages/dev-toolbelt-enums)
```

###  Alternatives

[firebase/php-jwt

A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.

9.8k445.7M2.1k](/packages/firebase-php-jwt)[lcobucci/jwt

A simple library to work with JSON Web Token and JSON Web Signature

7.5k316.6M895](/packages/lcobucci-jwt)[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[paragonie/sodium_compat

Pure PHP implementation of libsodium; uses the PHP extension if it exists

930131.6M155](/packages/paragonie-sodium-compat)[web-token/jwt-framework

JSON Object Signing and Encryption library for PHP and Symfony Bundle.

94818.9M77](/packages/web-token-jwt-framework)

PHPackages © 2026

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