Skip to content

Instantly share code, notes, and snippets.

@KasaiMagi
Last active December 10, 2015 22:58
Show Gist options
  • Save KasaiMagi/4505901 to your computer and use it in GitHub Desktop.
Save KasaiMagi/4505901 to your computer and use it in GitHub Desktop.
tell, dont ask example
<?php
class InvoiceManager
{
private $em;
private $invoiceRepo;
private $highValue;
public function __construct(EntityManager $em, $highValue)
{
$this->em = $em;
$this->invoiceRepo = $em->getRepository('Invoice');
$this->highValue = $highValue;
}
public function getInvoice($id)
{
return $this->invoiceRepo->find($id);
}
public function isHighValuedInvoice($id)
{
return $this->getInvoice($id)->getTotal() > $this->highValue;
}
}
class IndexController extends Controller
{
public function indexAction()
{
$invoiceManager = $this->container->get('manager.invoice')
$this->view->highValuedInvoice = $invoiceManager->isHighValuedInvoice($id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment