PHPackages                             tourze/operation-system-enum - 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. tourze/operation-system-enum

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

tourze/operation-system-enum
============================

Operation System Enum

1.0.0(6mo ago)03411MITPHPCI passing

Since May 25Pushed 6mo agoCompare

[ Source](https://github.com/tourze/operation-system-enum)[ Packagist](https://packagist.org/packages/tourze/operation-system-enum)[ RSS](/packages/tourze-operation-system-enum/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (1)

Operation System Enum
=====================

[](#operation-system-enum)

[English](README.md) | [中文](README.zh-CN.md)

A PHP 8.1+ enum package for representing different operating system platforms with support for label display, array conversion, and compatibility with frontend parameters.

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

[](#installation)

```
composer require tourze/operation-system-enum
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use Tourze\OperationSystemEnum\Platform;

// Get all platform cases
$platforms = Platform::cases();

// Get platform by value
$platform = Platform::from('WINDOWS');

// Get platform with fallback
$platform = Platform::tryFrom('INVALID'); // returns null

// Get platform label
echo Platform::WINDOWS->getLabel(); // "Windows"
echo Platform::ANDROID->getLabel(); // "安卓"
```

### Advanced Usage

[](#advanced-usage)

```
use Tourze\OperationSystemEnum\Platform;

// Mixed input support with compatibility
$platform = Platform::mixFrom('mac');     // returns Platform::MACOS
$platform = Platform::mixFrom('darwin');  // returns Platform::MACOS
$platform = Platform::mixFrom('win');     // returns Platform::WINDOWS
$platform = Platform::mixFrom('win32');   // returns Platform::WINDOWS

// Convert to array format
$data = Platform::WINDOWS->toArray();
// Returns: ['value' => 'WINDOWS', 'label' => 'Windows']

// Generate select options for frontend
$options = Platform::genOptions();
// Returns array of ['label' => '...', 'text' => '...', 'value' => '...', 'name' => '...']
```

### Available Platforms

[](#available-platforms)

- `Platform::EMPTY` - Empty/Unknown platform
- `Platform::WINDOWS` - Microsoft Windows
- `Platform::ANDROID` - Android OS
- `Platform::IOS` - Apple iOS
- `Platform::MACOS` - Apple macOS
- `Platform::ROUTER` - Router systems

### Features

[](#features)

- **Type Safety**: Built on PHP 8.1+ enums with strict typing
- **Labelable**: Implements `Labelable` interface for display labels
- **Itemable**: Implements `Itemable` interface for array conversion
- **Selectable**: Implements `Selectable` interface for frontend options
- **Compatibility**: Support for various input formats via `mixFrom()` method
- **Internationalization**: Labels in multiple languages (English/Chinese)

Configuration
-------------

[](#configuration)

This package requires no additional configuration. It works out of the box with:

- PHP 8.1 or higher
- `tourze/enum-extra` package for trait implementations

API Reference
-------------

[](#api-reference)

### Methods

[](#methods)

- `getLabel(): string` - Get display label for the platform
- `toArray(): array` - Convert to array with value and label
- `toSelectItem(): array` - Convert to select option format
- `static mixFrom(string $value): ?Platform` - Create platform from mixed input
- `static genOptions(): array` - Generate all platform options for frontend

### Interfaces

[](#interfaces)

- `Labelable` - Provides label display functionality
- `Itemable` - Provides array conversion functionality
- `Selectable` - Provides select option generation functionality

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance66

Regular maintenance activity

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Total

3

Last Release

200d ago

Major Versions

0.0.2 → 1.0.02025-10-31

### Community

Maintainers

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

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-operation-system-enum/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-operation-system-enum/health.svg)](https://phpackages.com/packages/tourze-operation-system-enum)
```

PHPackages © 2026

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