定制 gooh/interface-distiller 二次开发

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

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

gooh/interface-distiller

Composer 安装命令:

composer require gooh/interface-distiller

包简介

Derives Interfaces from the API of a class

README 文档

README

InterfaceDistiller allows you to derive Interfaces from the API of a class.

Scrutinizer Code Quality Build Status

Basic Usage Example

Interface Distiller can either be used a) programmatically, b) via a Builder or c) via the command line. Using it programmatically offers the greatest flexibility but is usually not needed. The Builder offers a convenient way to configure distillation of interfaces. The command line interface is a wrapper around the Builder and offers the same options.

Example 1 - Using the Builder

<?php
$distiller = new InterfaceDistiller;
$distiller
    ->methodsWithModifiers(\ReflectionMethod::IS_PUBLIC)
    ->extendInterfaceFrom('Iterator, SeekableIterator')
    ->excludeImplementedMethods()
    ->excludeInheritedMethods()
    ->excludeMagicMethods()
    ->excludeOldStyleConstructors()
    ->filterMethodsByPattern('(^get)')
    ->saveAs(new SplFileObject('MyInterface.php'))
    ->distill('SomeFoo', 'MyInterface');

With the notable exception of the distill and reset method, all other public methods provide a Fluent Interface. Calling distill will create a new interface from the specified class and given configuration. The source class is not altered in any way (it's not extraction). Subsequent calls to distill will use the same configuration unless reset was called.

Example 2 - Using the Commandline Interface

To use the Commandline Interface, you have to run build/create_phar.php to build a phar file previously.

    Usage: phpdistill [options] <classname> <interfacename>

      --bootstrap                           Path to File containing your bootstrap and autoloader

      --methodsWithModifiers <number>       A ReflectionMethod Visibility BitMask. Defaults to Public.
      --extendInterfaceFrom  <name,...>     Comma-separated list of Interfaces to extend.
      --excludeImplementedMethods           Will exclude all implemented methods.
      --excludeInheritedMethods             Will exclude all inherited methods.
      --excludeMagicMethods                 Will exclude all magic methods.
      --excludeOldStyleConstructors         Will exclude Legacy Constructors.
      --filterMethodsByPattern <pattern>    Only include methods matching PCRE pattern.
      --saveAs                              Filename to save new Interface to. STDOUT if omitted.

The CommandLine Interface requires you to set the pathname to your bootstrap file in the --bootstrap option. Your bootstrap file should contain all the necessary logic to include any classes you want derive interfaces from, e.g. autoloaders, include paths, etc. Without that you will only be able to distill from native classes.

If you installed InterfaceDistiller through the Composer package manager, the commandline tool will try to include the autoloader in the vendor directory.

The Commandline Interface will always reset configuration between calls. This means you need to specify the full configuration for each class you want to distill interfaces from.

Example 3 - Using the progammatic approach

A programmatic example can be found in the examples folder. In general, you will only need this approach if you need to add, modify or swap out internal components.

统计信息

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

GitHub 信息

  • Stars: 35
  • Watchers: 4
  • Forks: 8
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固