Skip to content

MrFerrys/Command_Pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command Pattern Concept

Command pattern concept based on refactoring.guru and designpatterns solutions.

Description

Command pattern concept.

Getting Started

Dependencies

  • PHP >= 5
  • ex. Command line

Executing program

  • How to run a basic command.
    $invoker = new Invoker();
    $receiver = new SimpleCommand('Hello world');
    $invoker->setCommand($receiver);
    $invoker->run();
  • How to run a complex command.
    $invoker = new Invoker();
    $receiver = new SimpleCommand('Hello world');
    $invoker->setCommand(new ComplexCommand($receiver,"Param_A","Param_B"));
    $invoker->run();
  • How to run a nested complex command .
    $invoker        =   new Invoker();
    $receiver       =   new SimpleCommand('Hello worlddd');
	$complexCommand =   new ComplexCommand($receiver,'PARAM_AA','PARAM_BB');
    $invoker->setCommand(new ComplexCommand($complexCommand,'PARAM_A','PARAM_B'));
    $invoker->run();
  • How to run a nested complex command aSync.
    $invoker        =   new Invoker();
    $receiver       =   new SimpleCommand('Hello worlddd');
    $complexCommand =   new ComplexCommand($receiver,'PARAM_AA','PARAM_BB');
    $invoker->setCommand(new ComplexCommand($complexCommand,'PARAM_A','PARAM_B',false));
    $invoker->run();

Authors

Ferrys

Version History

  • 1.0.0
    • Initial Release (X.Y.Z MAJOR.MINOR.PATCH)
  • 1.1.0
    • Verbosity level added
    • Folder name has changed from lib to src
    • lib name has changed from cmdlib to cmd

License

This project is licensed under the MiT License - see the LICENSE.txt file for details

Acknowledgments

Based on/Inspired By:

About

Command Pattern Concept

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages