承接 grifart/equalable-utils 相关项目开发

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

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

grifart/equalable-utils

最新稳定版本:v1.0.4

Composer 安装命令:

composer require grifart/equalable-utils

包简介

Provides a universal equals() function.

README 文档

README

Are objects equal or not? PHP defines only instance equality using === operator. Then there is comparision by value == which compares by object values, but user-land code cannot modify how they are compared.

This is why universal equals() method exists in Java. PHP is missing anything like that.

This is why I have implemented global equals() function provides logic equality of objects. Which objects are equal and which not can be modified by several things - see bellow.

Installation

composer require grifart/equalable-utils

Implementing logical equality

There are several ways of implementhing logic equality.

\Ds\Hashable (from PHP DS extension)

Hashable is PHP clone of Java equals() and hashCode() method. If you like to use implementing objects in collection this would make the most sense.

\Comparable interface proposal

This library supports \Comparable interface and tries to compare objects.

Just implement equals($other), is($other) or isEqualTo($other) methods

This methods must behave the same as Java equals() method.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-27