ephpicman/boolean-utility 问题修复 & 功能扩展

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

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

ephpicman/boolean-utility

Composer 安装命令:

composer require ephpicman/boolean-utility

包简介

A comprehensive Boolean utility for PHP, supporting logical operations, counting, and majority evaluation.

README 文档

README

License: MIT

A comprehensive PHP utility for working with booleans and boolean-like values.
Designed to simplify boolean checks, logical operations, counting, and majority logic in PHP projects.

Table of Contents

Installation

Use Composer to install:

composer require ephpicman/boolean-utility

Autoloading is PSR-4 compliant:

use EphpicMan\BooleanUtility\BooleanUtility;

Usage

The BooleanUtility class provides tools for:

  • Boolean type checks
  • Conversion of various values to boolean
  • Logical operations (AND, OR, XOR, etc.)
  • Counting true/false values
  • Determining majority
  • Aliases and toggle operations

Class: BooleanUtility

Checking Methods

MethodDescription
is(mixed $variable): boolChecks if a variable is strictly boolean.
isNot(mixed $variable): boolChecks if a variable is not boolean.
isTruthy(mixed $variable): boolChecks if a value evaluates to true.
isFalsy(mixed $variable): boolChecks if a value evaluates to false.

Conversion

MethodDescription
toBoolean(mixed ...$variables): bool | arrayConverts values to boolean. Strings matching true values, numbers, booleans, and arrays are all supported.

Logical Operations

MethodDescription
and(mixed ...$variables): boolLogical AND across multiple values.
nand(mixed ...$variables): boolLogical NAND across multiple values.
or(mixed ...$variables): boolLogical OR across multiple values.
nor(mixed ...$variables): boolLogical NOR across multiple values.
xor(mixed ...$variables): boolLogical XOR across multiple values.
xnor(mixed ...$variables): boolLogical XNOR across multiple values.
not(bool ...$variables): bool | arrayLogical NOT / toggle boolean values.

Counting Methods

MethodDescription
countTrue(mixed ...$variables): intCounts how many inputs are true.
countFalse(mixed ...$variables): intCounts how many inputs are false.

Majority Methods

MethodDescription
majorityTrue(mixed ...$variables): boolReturns true if the majority of inputs are true.
majorityFalse(mixed ...$variables): boolReturns true if the majority of inputs are false.
majority(mixed ...$variables): bool | nullReturns the majority value (true or false). Returns null if tie.

Aliases

MethodDescription
allTrue(...$vars): boolAlias for and().
allFalse(...$vars): boolAlias for nor().
xand(...$vars): boolAlias for and().
xnand(...$vars): boolAlias for nand().
anyTrue(...$vars): boolAlias for or().
anyFalse(...$vars): boolAlias for nor().

Toggle

MethodDescription
toggle(bool ...$variables): bool | arrayAlias for not().

Examples

use EphpicMan\BooleanUtility\BooleanUtility;

// Simple boolean checks
BooleanUtility::is(true);       // true
BooleanUtility::isNot('test');  // true

// Convert mixed values
BooleanUtility::toBoolean('yes');   // true
BooleanUtility::toBoolean(0);       // false
BooleanUtility::toBoolean([1, 'no']); // [true, false]

// Logical operations
BooleanUtility::and(true, 'yes', 1);  // true
BooleanUtility::or(false, 0, 'ok');   // true
BooleanUtility::xor(true, true, false); // false

// Counting
BooleanUtility::countTrue(true, false, 'yes');  // 2
BooleanUtility::countFalse(true, false, 'yes'); // 1

// Majority
BooleanUtility::majorityTrue(true, false, 'yes'); // true
BooleanUtility::majority(false, false, true, true); // null (tie)

// Toggle
BooleanUtility::toggle(true, false); // [false, true]

License

This package is released under the MIT License. Anyone may use, modify, or distribute it personally or commercially.

Git Repository

https://git.ephpic.org/ephpicman/boolean-utility

ephpicman/boolean-utility 适用场景与选型建议

ephpicman/boolean-utility 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 ephpicman/boolean-utility 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-04