承接 ilexn/result-option 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ilexn/result-option

Composer 安装命令:

composer require ilexn/result-option

包简介

Rust like enum Result and Option.

README 文档

README

Just for fun, Just feel Rust, Rust like enum Result and Option.

Latest Stable Version Total Downloads

GitHub Action Coverage Status Mutation testing badge

Installation

composer require ilexn/result-option

Usage example

<?php
declare(strict_types=1);

use Ilex\ResultOption\Option\Option;

require_once __DIR__ . '/../vendor/autoload.php';


$some = Option::some('any_value');
if ($some->isSome()){
   $value = $some->unwrap();
}

API

Take a look in the test folder for details

None (Ilex\ResultOption\Tests\Option\None)
✔ default() return None
✔ isSome() return false
✔ isNone() return true
✔ contains() any value return false
✔ expect() throw if the value is a [None] with a custom message.
✔ unwrap() throw if the self value equals [None].
✔ unwrapOr() Returns a provided default.
✔ unwrapOrElse() computes it from a closure.
✔ Returns [None] if the option is [None], otherwise returns input. with data set "null"
✔ Returns [None] if the option is [None], otherwise returns input. with data set "int"
✔ Returns [None] if the option is [None], otherwise returns input. with data set "string"
✔ Returns [None] if the option is [None], otherwise returns input. with data set "object"
✔ And then
✔ filter() Returns [None] if the option is [None]
✔ replace() Replaces the actual value in the option
✔ flatten() Converts from Option<Option<T>> to Option<T>

Some (Ilex\ResultOption\Tests\Option\Some)
✔ from() return Some with data set "null"
✔ from() return Some with data set "int"
✔ from() return Some with data set "string"
✔ from() return Some with data set "object"
✔ isSome() return true with data set "null"
✔ isSome() return true with data set "int"
✔ isSome() return true with data set "string"
✔ isSome() return true with data set "object"
✔ isNone() return false with data set "null"
✔ isNone() return false with data set "int"
✔ isNone() return false with data set "string"
✔ isNone() return false with data set "object"
✔ contain() with same value return true with data set "null"
✔ contain() with same value return true with data set "int"
✔ contain() with same value return true with data set "string"
✔ contain() with same value return true with data set "object"
✔ contain() with other NULL return false
✔ contain() with other 2 return false
✔ contain() with other hello return false
✔ contain() with other stdClass return false
✔ expect() returns the contained [Some] value. with data set "null"
✔ expect() returns the contained [Some] value. with data set "int"
✔ expect() returns the contained [Some] value. with data set "string"
✔ expect() returns the contained [Some] value. with data set "object"
✔ unwrap() Returns the contained [Some] value. with data set "null"
✔ unwrap() Returns the contained [Some] value. with data set "int"
✔ unwrap() Returns the contained [Some] value. with data set "string"
✔ unwrap() Returns the contained [Some] value. with data set "object"
✔ unwrapOr() Returns the contained [Some] value. with data set "null"
✔ unwrapOr() Returns the contained [Some] value. with data set "int"
✔ unwrapOr() Returns the contained [Some] value. with data set "string"
✔ unwrapOr() Returns the contained [Some] value. with data set "object"
✔ unwrapOrElse() Returns the contained [Some] value with data set "null"
✔ unwrapOrElse() Returns the contained [Some] value with data set "int"
✔ unwrapOrElse() Returns the contained [Some] value with data set "string"
✔ unwrapOrElse() Returns the contained [Some] value with data set "object"
✔ Returns [None] if the option is [None], otherwise returns input. with data set "null"
✔ Returns [None] if the option is [None], otherwise returns input. with data set "int"
✔ Returns [None] if the option is [None], otherwise returns input. with data set "string"
✔ Returns [None] if the option is [None], otherwise returns input. with data set "object"
✔ Returns [None] if the option is [None], otherwise calls f with
✔ filter() Returns [None] if the option is [None], otherwise calls
✔ replace() Replaces the actual value in the option by the value with data set "null"
✔ replace() Replaces the actual value in the option by the value with data set "int"
✔ replace() Replaces the actual value in the option by the value with data set "string"
✔ replace() Replaces the actual value in the option by the value with data set "object"
✔ flatten() Converts from Option<Option<T>> to Option<T> with data set "null"
✔ flatten() Converts from Option<Option<T>> to Option<T> with data set "int"
✔ flatten() Converts from Option<Option<T>> to Option<T> with data set "string"
✔ flatten() Converts from Option<Option<T>> to Option<T> with data set "object"
✔ flatten() throw when value is not [option] with data set "null"
✔ flatten() throw when value is not [option] with data set "int"
✔ flatten() throw when value is not [option] with data set "string"
✔ flatten() throw when value is not [option] with data set "object"

Err (Ilex\ResultOption\Tests\Result\Err)
✔ Is ok
✔ Is err
✔ Expect
✔ Unwrap
✔ Expect err
✔ Unwrap err
✔ Unwrap or
✔ Ok
✔ Err

Ok (Ilex\ResultOption\Tests\Result\Ok)
✔ Is ok with data set "null"
✔ Is ok with data set "int"
✔ Is ok with data set "string"
✔ Is ok with data set "object"
✔ Is err with data set "null"
✔ Is err with data set "int"
✔ Is err with data set "string"
✔ Is err with data set "object"
✔ Expect with data set "null"
✔ Expect with data set "int"
✔ Expect with data set "string"
✔ Expect with data set "object"
✔ Unwrap with data set "null"
✔ Unwrap with data set "int"
✔ Unwrap with data set "string"
✔ Unwrap with data set "object"
✔ Expect err with data set "null"
✔ Expect err with data set "int"
✔ Expect err with data set "string"
✔ Expect err with data set "object"
✔ Unwrap err with data set "null"
✔ Unwrap err with data set "int"
✔ Unwrap err with data set "string"
✔ Unwrap err with data set "object"
✔ Unwrap or with data set "null"
✔ Unwrap or with data set "int"
✔ Unwrap or with data set "string"
✔ Unwrap or with data set "object"
✔ Ok with data set "null"
✔ Ok with data set "int"
✔ Ok with data set "string"
✔ Ok with data set "object"
✔ Err with data set "null"
✔ Err with data set "int"
✔ Err with data set "string"
✔ Err with data set "object"

ilexn/result-option 适用场景与选型建议

ilexn/result-option 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.15k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「enum」 「option」 「result」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ilexn/result-option 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ilexn/result-option 我们能提供哪些服务?
定制开发 / 二次开发

基于 ilexn/result-option 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-03