Skip to content

Instantly share code, notes, and snippets.

@viniciusss
Created August 20, 2014 23:49
Show Gist options
  • Save viniciusss/78d11eaf4b8552624ce4 to your computer and use it in GitHub Desktop.
Save viniciusss/78d11eaf4b8552624ce4 to your computer and use it in GitHub Desktop.
<?php
class Chamado {
private $id;
private $descricao;
private $status;
}
class Chamdo_Builder {
public function build(array $dados){
$chamado = new Chamado();
$chamado->setId($dados['id']);
}
public function populate(Chamado $chamado, array $dados) {
}
}
class Chamdao_Service {
/**
* Local onde serão armazenados os dados
* @var Repository
*/
private $repository;
/**
* @var Chamado_Builder
*/
private $builder;
public function __construct(Repository $repository, Builder $builder){
$this->repository = $repository;
}
public function buscarPendentes(){
$pendentes = $this->repository->findByAreaAtuacaoStatus($_SESSION['areas_responsaveis']);
foreach($pendentes as $pendente) {
yeld $this->builder->build($pendente);
}
}
public function save(array $dados, Chamado $chamado = null){
if(is_null($chamado)) {
$chamado = new Chamado();
}
$this->builder->populate($chamado, $dados);
$this->repository->save($chamado);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment