arielespinoza07/result-pattern 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arielespinoza07/result-pattern

最新稳定版本:v2.1.0

Composer 安装命令:

composer require arielespinoza07/result-pattern

包简介

A modern implementation of the Result pattern for handling operation outcomes and HTTP responses

README 文档

README

Build Status Total Downloads Latest Stable Version License

A modern and simple implementation of the Result pattern for handling operation outcomes or HTTP responses.

**Requires PHP 8.3+ **

Features

  • 🛡️ Type-safe result handling with strict type hints
  • 🌐 Complete HTTP response status codes support (1xx to 5xx)
  • 🔒 Immutable objects using PHP 8.3+ readonly classes
  • 🎯 SOLID principles adherence
  • 🧩 Composable and extensible design
  • 📝 Comprehensive test suite with Pest PHP

Project Structure

src/
├── Enums/
│   └── HttpResponseStatusCode.php
├── Failure.php
├── Success.php
└── Result.php

Installation

composer require arielespinoza07/result-pattern

Documentation

The following documentation files provide examples and usage patterns for the Result pattern:

Available Response Codes

  • Informational Responses (1xx)
  • Success Responses (2xx)
  • Redirection Responses (3xx)
  • Client Error Responses (4xx)
  • Server Error Responses (5xx)

Development

Requirements

  • PHP 8.3+
  • Composer 2.0+

Installation

composer require arielespinoza07/result-pattern

Development Installation

git https://github.com/ArielEspinoza07/result-pattern.git
cd result-pattern
composer install

Quality Tools

This package uses several tools to ensure code quality:

# Run all checks
composer test

# Run specific checks
composer test:lint     # Check code style
composer test:types    # Run static analysis
composer test:unit     # Run unit tests
composer test:coverage # Check test coverage

Continuous Integration

GitHub Actions automatically run the following checks on push and pull requests:

  • Static analysis with PHPStan (level max)
  • Unit tests with Pest PHP
  • Code style with Laravel Pint
  • Type coverage check
  • Typo check with Peck

Testing

This package uses Pest PHP for testing. To run the tests:

composer test

To generate a coverage report:

composer test:coverage

The coverage report will be available in the coverage directory.

Development Tools

This package uses several development tools: to ensure code quality and maintainability:

Code Quality Tools

  • Pest PHP: Modern Testing Framework with custom expectations

    composer test           # Run tests
    composer test:coverage  # Run tests with coverage report
  • Laravel Pint: PSR-12 Code Style Fixer

    composer pint      # Fix code style
    composer pint:test # Check code style
  • PHPStan: Static Analysis (Level 9)

    composer analyse   # Run static analysis
  • Rector: PHP 8.3 Compatibility and Code Quality

    composer rector    # Run code quality checks

License

MIT License

统计信息

  • 总下载量: 58
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-09