-
-
Save leocavalcante/642d035c5d5715191c04 to your computer and use it in GitHub Desktop.
This file contains 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 Support {} | |
class TechnicalSupport implements Support {} | |
class FinancialSupport implements Support {} | |
class AdministrativeSupport implements Support {} | |
class SupportFactory | |
{ | |
public function createByType($type) | |
{ | |
$class = $type.'Support'; | |
if (!class_exists($class)) { | |
throw new InvalidArgumentException("there is no class $class"); | |
} | |
return new $class; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment