Skip to content

Instantly share code, notes, and snippets.

@Ronmi
Created October 31, 2017 03:37
Show Gist options
  • Save Ronmi/5960f2b46e8cb4930f40092cb371d6cc to your computer and use it in GitHub Desktop.
Save Ronmi/5960f2b46e8cb4930f40092cb371d6cc to your computer and use it in GitHub Desktop.
poorman IoC
<?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