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-04-21 04:46:23 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