Created
May 2, 2014 17:09
-
-
Save davidchc/da172bb283196f87c0fa to your computer and use it in GitHub Desktop.
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 | |
//Define a interface, para usar melhor o polimorfismo | |
interface Shipping{ | |
public function calculate(); | |
} | |
//Cria uma classe abstrata, vai define alguns valores padrões | |
abstract class AbstractShipping implements Shipping{ | |
protected $weight; | |
protected $total; | |
protected $zipcodeOrign; | |
protected $zipcodeDestination; | |
} | |
//Classe especialista, dará ação pra os Correios | |
class CorreioShipping extends AbstractShipping{ | |
public function calculate(){ | |
} | |
} | |
//Classe especialista, dará ação pra os Transportadora | |
class TransportadoraShipping extends AbstractShipping{ | |
public function calculate(){ | |
} | |
} | |
//O checkout, q vai utilizar o calculo do frete, | |
//Aqui não importa como será o calculo, e sim | |
//q ele terá q usar o Interface Shipping | |
class Checkout{ | |
private $shipping; | |
public function setShipping(Shipping $shipping){ | |
$this->shipping = $shipping | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment