skobka/command-pattern

用于与命令设计模式交互的有用接口集

dev-master 2018-08-07 05:30 UTC

This package is not auto-updated.

Last update: 2024-09-22 06:40:58 UTC


README

Build Status Maintainability codecov

这里是一组用于命令设计模式的接口和辅助实现。

包含内容

  • CommandInterface
  • ResultInterface
  • ParametrizedCommand
  • ParametrizedResultedCommand

如何使用

只需让您的类实现可用的接口之一

<?php

use skobka\CommandPattern\CommandInterface;

class MyCoolCommand implements CommandInterface {
    /**
     * @inheritdoc  
     */
    public function execute() : void
    {
        // write your actions here
    }
}

class CommandFactory {
    public static function create(): CommandInterface
    {
        return new MyCoolCommand();
    }
}

$command = CommandFactory::create();
$command->execute();

路线图

  • 撤销/重做命令
  • 通用结果命令
  • 类型参数
  • Symfony 依赖注入示例