Last active
December 1, 2023 01:12
-
-
Save IgorDePaula/230cdd51f38351b6fd9795c7fe469153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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