Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Last active December 1, 2023 01:12
Show Gist options
  • Save IgorDePaula/230cdd51f38351b6fd9795c7fe469153 to your computer and use it in GitHub Desktop.
Save IgorDePaula/230cdd51f38351b6fd9795c7fe469153 to your computer and use it in GitHub Desktop.
<?php
interface Pass {
public funcion execute();
}
class Pass1 implements Pass{
public funcion execute(){
// todo
}
}
class Pass2 implements Pass{
public funcion execute(){
// todo
}
}
class Pass3 implements Pass{
public funcion execute(){
// todo
}
}
class ExecutePass {
private $passes = [];
public function addPass(Pass $pass){
$this->passes[] = $pass;
}
public function executeComand(){
foreach ($this->passes as $pass){
$pass->execute();
}
}
}
$passManager = new ExecutePass();
$passManager->addPass(new Pass1());
$passManager->addPass(new Pass2());
$passManager->addPass(new Pass3());
$passManager->executeCommand();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment