Last active
January 12, 2024 23:31
-
-
Save giovanisilveira/aaac0fb634ba98e88507 to your computer and use it in GitHub Desktop.
Factory PHP
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 Atendimento | |
{ | |
const SUPORTE = 1; | |
const FINANCEIRO = 2; | |
const ADMINISTRATIVO = 3; | |
public function encerrar(); | |
} | |
class Suporte implements Atendimento | |
{ | |
public function encerrar() | |
{ | |
return "Encerrar Suporte"; | |
} | |
} | |
class Financeiro implements Atendimento | |
{ | |
public function encerrar() | |
{ | |
return "Encerrar Financeiro"; | |
} | |
} | |
class Administrativo implements Atendimento | |
{ | |
public function encerrar() | |
{ | |
return "Encerrar Administrativo"; | |
} | |
} | |
class AtendimentoFactory | |
{ | |
public static function getAtendimentoPorTipo($tipo) | |
{ | |
switch ($tipo) { | |
case Atendimento::SUPORTE : return new Suporte(); | |
case Atendimento::FINANCEIRO : return new Financeiro(); | |
case Atendimento::ADMINISTRATIVO : return new Administrativo(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment