定制 lightningspirit/magic-interfaces 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

lightningspirit/magic-interfaces

最新稳定版本:1.1.0

Composer 安装命令:

composer require lightningspirit/magic-interfaces

包简介

Provides PHP Interfaces to test some magic methods using instanceof instead of method_exists

README 文档

README

Latest Stable Version Build Status License ![Gitter](https://badges.gitter.im/Join Chat.svg)

PHP Interfaces for magic methods

This package provides interfaces that define PHP magic methods.

Using interfaces to test for existing implementations is often recognized as a best practice.

When testing objects for magic methods implementation, those interfaces can be useful.

Motivation

Instead of:

if (method_exists('__invoke', $object)) {
    $object();
}

one can now write:

if ($object instanceof Invokable) {
    $object();
}

Usage example

Create a class that implements some magic interfaces.

/**
 * Implement some magic methods by using interfaces
 */
class Example implements Invokable, Stringifiable {

}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-14