Compare commits

..

2 Commits

Author SHA1 Message Date
rhalberstadt c492c52284 Standardize .gitignore and added missing license
PHP Composer / build (push) Successful in 41s
2026-07-26 20:22:29 +02:00
rhalberstadt 5f8f7b9a28 Updated README and .gitignore
PHP Composer / build (push) Successful in 42s
2026-07-26 20:10:22 +02:00
18 changed files with 40 additions and 81 deletions
+1 -7
View File
@@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Validate composer.json and composer.lock - name: Validate composer.json and composer.lock
run: composer validate --strict --no-check-lock run: composer validate --strict
- name: Cache Composer packages - name: Cache Composer packages
id: composer-cache id: composer-cache
@@ -29,12 +29,6 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-php- ${{ runner.os }}-php-
- name: Configure GitHub OAuth for Composer
if: ${{ env.GH_COMPOSER_TOKEN != '' }}
env:
GH_COMPOSER_TOKEN: ${{ secrets.GH_COMPOSER_TOKEN }}
run: composer config --global github-oauth.github.com ${{ secrets.GH_COMPOSER_TOKEN }}
- name: Install dependencies - name: Install dependencies
run: composer install --prefer-dist --no-progress run: composer install --prefer-dist --no-progress
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2026 René Halberstadt Copyright (c) 2026 Development
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including associated documentation files (the "Software"), to deal in the Software without restriction, including
+9 -25
View File
@@ -1,10 +1,5 @@
# tez-utils-enum # tez-utils-enum
[![CI](https://github.com/tezmanian/tez-utils-enum/actions/workflows/php.yml/badge.svg)](https://github.com/tezmanian/tez-utils-enum/actions/workflows/php.yml)
[![Packagist Version](https://img.shields.io/packagist/v/tezmanian/utils-enum)](https://packagist.org/packages/tezmanian/utils-enum)
[![PHP](https://img.shields.io/packagist/php-v/tezmanian/utils-enum)](https://packagist.org/packages/tezmanian/utils-enum)
[![License: MIT](https://img.shields.io/packagist/l/tezmanian/utils-enum)](LICENSE)
Composable PHP 8.3 traits that extend native enums with lookup, comparison, navigation, bitmask, label, and collection helpers. Composable PHP 8.3 traits that extend native enums with lookup, comparison, navigation, bitmask, label, and collection helpers.
**Zero dependencies** · **PHPStan level 9** · **MIT** **Zero dependencies** · **PHPStan level 9** · **MIT**
@@ -12,11 +7,9 @@ Composable PHP 8.3 traits that extend native enums with lookup, comparison, navi
## Installation ## Installation
```bash ```bash
composer require tezmanian/utils-enum composer require tez/utils-enum
``` ```
Package: [`tezmanian/utils-enum`](https://packagist.org/packages/tezmanian/utils-enum) · Namespace: `Tezmanian\Utils\Enum`
Requires PHP ≥ 8.3. Requires PHP ≥ 8.3.
## Traits ## Traits
@@ -38,7 +31,7 @@ Requires PHP ≥ 8.3.
Base trait for pure (unit) enums. Use `BackedEnumTrait` instead when your enum has backing values. Base trait for pure (unit) enums. Use `BackedEnumTrait` instead when your enum has backing values.
```php ```php
use Tezmanian\Utils\Enum\EnumTrait; use Tez\Utils\Enum\EnumTrait;
enum Status enum Status
{ {
@@ -85,7 +78,7 @@ Status::toArray(); // ['Draft' => 'Draft', 'Published' => 'Published', 'Archived
Extends `EnumTrait` for string- or int-backed enums. Overrides `is()` to match by backing value, and `toArray()` to return `[value => name]`. Extends `EnumTrait` for string- or int-backed enums. Overrides `is()` to match by backing value, and `toArray()` to return `[value => name]`.
```php ```php
use Tezmanian\Utils\Enum\BackedEnumTrait; use Tez\Utils\Enum\BackedEnumTrait;
enum Color: string enum Color: string
{ {
@@ -131,7 +124,7 @@ Bitmask helpers for int-backed enums used as flag sets. Case values must be powe
Does not include `BackedEnumTrait` — combine them explicitly if needed. Does not include `BackedEnumTrait` — combine them explicitly if needed.
```php ```php
use Tezmanian\Utils\Enum\BitFlagTrait; use Tez\Utils\Enum\BitFlagTrait;
enum Permission: int enum Permission: int
{ {
@@ -175,7 +168,7 @@ Permission::fromBitmask(0); // []
Comparison helpers for int-backed enums, comparing cases by their backing values. Comparison helpers for int-backed enums, comparing cases by their backing values.
```php ```php
use Tezmanian\Utils\Enum\ComparableTrait; use Tez\Utils\Enum\ComparableTrait;
enum Priority: int enum Priority: int
{ {
@@ -212,7 +205,7 @@ Navigate to adjacent cases by definition order. Designed for state machines and
Order is determined by **definition order** (ordinal), not backing value. Returns `null` at boundaries — no wrap-around. Order is determined by **definition order** (ordinal), not backing value. Returns `null` at boundaries — no wrap-around.
```php ```php
use Tezmanian\Utils\Enum\StepTrait; use Tez\Utils\Enum\StepTrait;
enum CheckoutStep enum CheckoutStep
{ {
@@ -245,7 +238,7 @@ CheckoutStep::PersonalInfo->prev(); // null (first step)
Human-readable labels for enum cases, without any framework dependency. Override `labels()` to supply custom mappings keyed by case name. Falls back to the case name when no label is defined. Human-readable labels for enum cases, without any framework dependency. Override `labels()` to supply custom mappings keyed by case name. Falls back to the case name when no label is defined.
```php ```php
use Tezmanian\Utils\Enum\TranslatableTrait; use Tez\Utils\Enum\TranslatableTrait;
enum UserRole enum UserRole
{ {
@@ -287,7 +280,7 @@ UserRole::labelsArray();
Collection-style selection helpers. Can be combined with `EnumTrait` or `BackedEnumTrait`. Works with any enum type. Collection-style selection helpers. Can be combined with `EnumTrait` or `BackedEnumTrait`. Works with any enum type.
```php ```php
use Tezmanian\Utils\Enum\EnumCollectionTrait; use Tez\Utils\Enum\EnumCollectionTrait;
enum Suit enum Suit
{ {
@@ -366,15 +359,6 @@ enum Permission: int
- PHP 8.3+ - PHP 8.3+
- No runtime dependencies - No runtime dependencies
## Development
```bash
make build && make install
make ci # audit, PHPStan, code style, tests
```
## License ## License
MIT — see [LICENSE](LICENSE). MIT
Author: René Halberstadt
+3 -22
View File
@@ -1,35 +1,16 @@
{ {
"name": "tezmanian/utils-enum", "name": "tez/utils-enum",
"type": "library", "type": "library",
"description": " A collection of PHP traits that supercharge native enums with comparison, bit-flag, stepping, collection, and translation helpers — zero dependencies, PHP 8.3+.", "description": " A collection of PHP traits that supercharge native enums with comparison, bit-flag, stepping, collection, and translation helpers — zero dependencies, PHP 8.3+.",
"keywords": [
"enum",
"traits",
"flags",
"bitflag",
"collection",
"php"
],
"homepage": "https://github.com/tezmanian/tez-utils-enum",
"license": "MIT", "license": "MIT",
"authors": [
{
"name": "René Halberstadt",
"email": "tezmanian@gmail.com"
}
],
"support": {
"issues": "https://github.com/tezmanian/tez-utils-enum/issues",
"source": "https://github.com/tezmanian/tez-utils-enum"
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Tezmanian\\Utils\\Enum\\": "src/" "Tez\\Utils\\Enum\\": "src/"
} }
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Tezmanian\\Utils\\Tests\\Enum\\": "tests/" "Tez\\Utils\\Tests\\Enum\\": "tests/"
} }
}, },
"require": { "require": {
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Enum; namespace Tez\Utils\Enum;
/** /**
* Extends EnumTrait for string- and int-backed enums. * Extends EnumTrait for string- and int-backed enums.
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Enum; namespace Tez\Utils\Enum;
/** /**
* Bitmask helpers for int-backed enums used as flag sets. * Bitmask helpers for int-backed enums used as flag sets.
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Enum; namespace Tez\Utils\Enum;
/** /**
* Comparison helpers for int-backed enums. * Comparison helpers for int-backed enums.
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Enum; namespace Tez\Utils\Enum;
/** /**
* Add-on trait providing collection-style selection helpers for any enum. * Add-on trait providing collection-style selection helpers for any enum.
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Enum; namespace Tez\Utils\Enum;
/** /**
* Base trait for pure (unit) enums. * Base trait for pure (unit) enums.
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Enum; namespace Tez\Utils\Enum;
/** /**
* Navigation helpers for stepping to the adjacent case by definition order. * Navigation helpers for stepping to the adjacent case by definition order.
+1 -1
View File
@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Enum; namespace Tez\Utils\Enum;
/** /**
* Provides human-readable labels for enum cases without any framework dependency. * Provides human-readable labels for enum cases without any framework dependency.
+2 -2
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Tests\Enum; namespace Tez\Utils\Tests\Enum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Tezmanian\Utils\Enum\BackedEnumTrait; use Tez\Utils\Enum\BackedEnumTrait;
// String-backed enum // String-backed enum
enum Color: string enum Color: string
+3 -3
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Tests\Enum; namespace Tez\Utils\Tests\Enum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Tezmanian\Utils\Enum\BackedEnumTrait; use Tez\Utils\Enum\BackedEnumTrait;
use Tezmanian\Utils\Enum\BitFlagTrait; use Tez\Utils\Enum\BitFlagTrait;
enum Permission: int enum Permission: int
{ {
+3 -3
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Tests\Enum; namespace Tez\Utils\Tests\Enum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Tezmanian\Utils\Enum\BackedEnumTrait; use Tez\Utils\Enum\BackedEnumTrait;
use Tezmanian\Utils\Enum\ComparableTrait; use Tez\Utils\Enum\ComparableTrait;
enum Level: int enum Level: int
{ {
+2 -2
View File
@@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Tests\Enum; namespace Tez\Utils\Tests\Enum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Tezmanian\Utils\Enum\EnumCollectionTrait; use Tez\Utils\Enum\EnumCollectionTrait;
enum Suit: string enum Suit: string
{ {
+3 -3
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Tests\Enum; namespace Tez\Utils\Tests\Enum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Tezmanian\Utils\Enum\BackedEnumTrait; use Tez\Utils\Enum\BackedEnumTrait;
use Tezmanian\Utils\Enum\EnumTrait; use Tez\Utils\Enum\EnumTrait;
// Pure (unit) enum used across all EnumTrait tests // Pure (unit) enum used across all EnumTrait tests
enum Season enum Season
+3 -3
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Tests\Enum; namespace Tez\Utils\Tests\Enum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Tezmanian\Utils\Enum\EnumTrait; use Tez\Utils\Enum\EnumTrait;
use Tezmanian\Utils\Enum\StepTrait; use Tez\Utils\Enum\StepTrait;
enum OrderStatus enum OrderStatus
{ {
+3 -3
View File
@@ -2,11 +2,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tezmanian\Utils\Tests\Enum; namespace Tez\Utils\Tests\Enum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Tezmanian\Utils\Enum\BackedEnumTrait; use Tez\Utils\Enum\BackedEnumTrait;
use Tezmanian\Utils\Enum\TranslatableTrait; use Tez\Utils\Enum\TranslatableTrait;
enum StatusWithLabels: string enum StatusWithLabels: string
{ {