skobka/command-pattern

The usefull set of interface to interact with command design pattern

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

This package is not auto-updated.

Last update: 2024-11-17 07:24:03 UTC


README

Build Status Maintainability codecov

Here is set of interfaces and helper implementations for Command design pattern.

What's included

  • CommandInterface
  • ResultInterface
  • ParametrizedCommand
  • ParametrizedResultedCommand

How to use

Just make your class implements one of available interfaces:

<?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();

Roadmap

  • Undo/Redo commands
  • Generic result command
  • Typed parameters
  • Symfony Dependency Injection examples