Last active
January 18, 2017 11:10
-
-
Save viniciusss/08c31dcba7c8eb0e5bf6dd6fc45439d0 to your computer and use it in GitHub Desktop.
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 | |
namespace Simonetti\Integrador\Brigde; | |
use Simonetti\Integrador\Destino\Requisicao; | |
class Rovereti | |
{ | |
public function getVersion(): string; | |
public function getName(): string; | |
public function execute(Requisicao $requisicao) | |
{ | |
switch($requisicao->getIdentificadorMetodo()) { | |
case 'IncluirPessoaJuridica': | |
$pessoaJuridica = new SDK\PessoaJuridica(); | |
$pessoaJuridica->populate($requisicao->getData()); | |
$pessoaJuridicaService->execute($pessoaJuridica); | |
break; | |
} | |
} | |
} |
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 | |
namespace Simonetti\Integrador\Destino; | |
class Creator | |
{ | |
public function create(Source\Requisicao $requisicao): array | |
{ | |
$requisicoes = []; | |
$dados = $this->fecthDados($requisicao); | |
foreach ($requisicao->getDestinos() as $destino) { | |
$data = $this->createData($destino, $dados); | |
$requisicoes[] = new Requisicao($requisicao, $data, $destino->getMetodo()); | |
} | |
return $requisicoes; | |
} | |
protected function fecthDados(Source\Requisicao $requisicao) | |
{ | |
$conn = $this->createConexao($requisicao->getConexao()); | |
$dados = $conn->fetchOne($requisicao->getSql(), $requisicao->getIdentificador()); | |
if(!$dados) { | |
// exeception | |
} | |
return $dados; | |
} | |
protected function createData(Source\Destino $destino, array $dados): stdClass | |
{ | |
$data = []; | |
foreach($dados as $oldKey => $value) { | |
$data[$destino->getKeyMapeamento($oldKey)] = $value; | |
} | |
return (object) $data; | |
} | |
} |
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 | |
namespace Simonetti\Integrador\Destino; | |
class Requisicao | |
{ | |
public function getRequisicaoSource(): Source; | |
public function getData(): stdClass; | |
public function getMetodo(): Destino\Metodo; | |
public function getIdentificadorMetodo(): string; | |
} | |
class Destino | |
{ | |
public function getId(): int; | |
public function getIdentificador(): string; | |
public function getNome(): string; | |
public function getBridge(): string; | |
public function getMetodos(): MetodosCollection; | |
} | |
class Metodo | |
{ | |
public function getId(); | |
public function getDescricao(); | |
public function getIdentificador(); | |
public function getParams(): array; | |
} |
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 | |
namespace Simonetti\Integrador\Source; | |
class Source | |
{ | |
public function getId(): int; | |
public function getIdentificador(): string; | |
public function getConexao(): Conexao; | |
public function getSql(): Sql; | |
public function getDestinos(): array; | |
} | |
class Source\Destino | |
{ | |
public function getDestino(): Destino\Destino; | |
public function getMetodo(): Destino\Metodo; | |
public function getMapeamento(): Mapeamento; | |
} | |
class Mapeamento | |
{ | |
public function getColunas(): array | |
} | |
class Requisicao | |
{ | |
public function getId(): int; | |
public function getSource(): Source; | |
public function getIdentificador(): string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment