Last active
August 29, 2015 14:03
-
-
Save Bolinha1/bf47b7a4767223c3f771 to your computer and use it in GitHub Desktop.
exemplo que fere alguns princípios S.O.L.I.D, um deles IoC, que nos diz o seguinte: "Módulos de alto nível não devem depender de módulos de baixo nível, ambos devem depender de abstrações"
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 | |
| class ItensVenda | |
| { | |
| private $item; | |
| public function addItens($item) | |
| { | |
| $this->item = $item; | |
| } | |
| public function getItens() | |
| { | |
| return $this->item; | |
| } | |
| } | |
| class Venda | |
| { | |
| private $itensVenda; | |
| public function setItens($produto) | |
| { | |
| //esse trecho de código é problemático | |
| $itens = new ItensVenda(); | |
| $itens->addItens($produto); | |
| $this->itensVenda[] = $itens; | |
| } | |
| public function getItensVenda() | |
| { | |
| return $this->itensVenda; | |
| } | |
| } | |
| $v1 = new Venda('01/07/2014'); | |
| $v1->itens("notebook"); | |
| $v1->itens("computer"); | |
| var_dump($v1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment