Last active
December 10, 2015 22:58
-
-
Save KasaiMagi/4505901 to your computer and use it in GitHub Desktop.
tell, dont ask example
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 | |
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