Created
October 31, 2017 03:37
-
-
Save Ronmi/5960f2b46e8cb4930f40092cb371d6cc to your computer and use it in GitHub Desktop.
poorman IoC
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 | |
class SomeClass { | |
public function process($c) { | |
if ($c instanceof ClassA) { | |
$this->processA($c); | |
} elseif ($c instanceof ClassB) { | |
$this->processB($c); | |
} else { | |
// error process | |
} | |
} | |
} | |
class RewriteAsIoC { | |
public function process($c) { | |
if ($c instanceof NewlyCreatedInterface) { | |
$c->processBy($this); | |
return; | |
} | |
// error process | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment