Skip to content

Instantly share code, notes, and snippets.

@giovanisilveira
Last active January 12, 2024 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save giovanisilveira/aaac0fb634ba98e88507 to your computer and use it in GitHub Desktop.
Save giovanisilveira/aaac0fb634ba98e88507 to your computer and use it in GitHub Desktop.
Factory PHP
<?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