Skip to content

Instantly share code, notes, and snippets.

@joaorobertopb
Created December 31, 2018 01:34
Show Gist options
  • Save joaorobertopb/712eda3e1598eeeeb1f3449532fac1e4 to your computer and use it in GitHub Desktop.
Save joaorobertopb/712eda3e1598eeeeb1f3449532fac1e4 to your computer and use it in GitHub Desktop.
Aplicação do princípio de responsabilidade única do SOLID.
<?php
class Order
{
public function calculateTotalSum(){/*...*/}
public function getItems(){/*...*/}
public function getItemCount(){/*...*/}
public function addItem($item){/*...*/}
public function deleteItem($item){/*...*/}
}
class OrderRepository
{
public function load($orderID){/*...*/}
public function save($order){/*...*/}
public function update($order){/*...*/}
public function delete($order){/*...*/}
}
class OrderViewer
{
public function printOrder($order){/*...*/}
public function showOrder($order){/*...*/}
}
//Reference: https://www.apphp.com/tutorials/index.php?page=solid-principles-in-php-examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment