承接 danielkellyio/value-comparison 相关项目开发

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

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

danielkellyio/value-comparison

最新稳定版本:1.0.0

Composer 安装命令:

composer require danielkellyio/value-comparison

包简介

Compare a value to another value in order to perform advanced logic on user input (comparisons such as greater than, starts with, contains and with any or all to compare against multiple)

README 文档

README

Compare value to another value in order to perform advanced logic on user input (comparisons such as greater than, starts with, contains and with any or all to compare against multiple)

Why Value Comparison Library?

Value comparison is simple, why have a library for it? My use case is to take an operator from user input (an html select field), so:

  1. Having the operators in word format solved 2 issues:
    • can't have dynamic operators
    • provides non-coder friendly terminology
  2. Having the ability to pass "any" or "all" (once again from user input comma separated seemed a no-brainer)
  3. Full test coverage for confidence that it'll works every time
  4. This makes ValueComparison perfectly fit to handle the input of a user interface like this: screenshot

Installation

composer require danielkellyio/value-comparison

Examples

use DanielKellyIO\ValueComparison\Compare;

// Check if string contains another string
Compare::value('Value to test')->contains('test'); // true

//Check if string contains ANY other strings (pass an array or string with values comma seperated)
Compare::value('Value to test')->contains('test, not, there', 'any'); // true
//or
Compare::value('Value to test')->contains(['test', 'not', 'there'], 'any'); // true

//Check if string contains ALL other strings (pass an array or string with values comma seperated)
Compare::value('Value to test')->contains('test, not, there', 'all'); // false
//or
Compare::value('Value to test')->contains(['test', 'not', 'there'], 'all'); // false

Methods

  • is - check if value is exact match to comparison value (coerced to string)
  • isNot - check if value is NOT an exact match to comparison value (coerced to string)
  • greaterThan - check if value is greater than comparison value (coerced to integer)
  • lessThan - check if value is less than comparison value (coerced to integer)
  • contains - check if value is contains comparison value (coerced to string)
  • excludes - check if value is excludes comparison value (coerced to string)
  • startsWith - check if value is starts with comparison value (coerced to string)
  • endsWith - check if value is ends with comparison value (coerced to string)

Scopes

  • null - treats comparison value as a single entity to compare against value
  • any - value only has to match one of the comparison values (comparison value can be array or comma seperated string)
  • all - value has to match ALL of the comparison values (comparison value can be array or comma seperated string)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固