Last active
December 17, 2016 12:59
-
-
Save viniciusalonso/b32ddb5b207ab946af26d9f322fbc821 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 | |
class Cart { | |
private $owner; | |
private $items; | |
public function __construct($owner, $items) { | |
$this->owner = $owner; | |
$this->items = $items; | |
} | |
public function totalValueOfItems() { | |
$total = 0; | |
foreach ($this->items as $item) { | |
$total += $item->getProduct()->getValue() * $item->getQuantity(); | |
} | |
return $total; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment