承接 aviator/makeable 相关项目开发

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

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

aviator/makeable

最新稳定版本:0.1.0

Composer 安装命令:

composer require aviator/makeable

包简介

Static constructor trait and interface.

README 文档

README

Build Status Latest Stable Version License

Overview

This package provides a static constructor interface, and a trait that implements the interface.

Installation

Via Composer:

composer require aviator/makeable

Testing

Via Composer:

composer test

Usage

Use the trait:

class Something
{
    use MakeableTrait;
}

Then the class can be instantiated using Class::make(...$args):

$instance = Something::make($arg1, $arg2);

The interface is optional, though it can be useful in composite interfaces to specify that a static constructor should be present:

interface SomeInterface extends Makeable, SomeOtherInterface
{
    /* ... etc */
}

Since the static constructor simply returns new static(...$args), it can be used in abstract classes and parent classes without having to re-use it on child classes:

abstract class Seuss
{
    use MakeableTrait;
}

class ThingOne extends Seuss {};
class ThingTwo extends ThingOne {};

// Get an instance of ThingOne
$instance = ThingOne::make();

// Get an instance of ThingTwo
$instance = ThingTwo::make();

Other

License

This package is licensed with the MIT License (MIT).

统计信息

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

GitHub 信息

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

其他信息

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