Tweeked by J. Reuben Wetherbee
Completely Based On Conference Talk
by Adam Wathan / @adamwathan
at Sunshine PHP Conference
Presentation in reveal.js
1984 | LOGO: Turtle Program | ![]() |
1989 | BASIC: Tripeaks Solitaire |
|
1999 | VBA/Access: Faculty Database (Medicine) | ![]() |
2001 | PHP: Faculty Database Online | ![]() |
"I don't really see the difference. Whether you have two elements in a statment, or two services in some distributed architecture, the principles are the same"
class SalesReport {
public function __construct($sales, $startDate, $endDate)
{
$this->sales = $sales;
$this->startDate = $startDate;
$this->endDate = $endDate;
}
public function totalRevenue()
{
$revenue = 0;
foreach($this->sales as $sale) {
if($sale->date >= $this->startDate && $sale->date <= $this->endDate) {
$revenue += $sale->value;
}
}
return $revenue;
}
}
class SalesReport {
public function __construct($sales, $startDate, $endDate)
{
$this->sales = $sales;
$this->startDate = $startDate;
$this->endDate = $endDate;
}
public function totalRevenue()
{
$revenue = 0;
foreach($this->sales as $sale) {
if($this->saleWithinRange($sale)){
$revenue += $sale->value;
}
}
return $revenue;
}
private function saleWithinRange($sale) {
if($sale->date >= $this->startDate && $sale->date <= $this->endDate) {
return true;
}
else return false;
}
}
class Book {
public function author() {
return $this->author;
}
}
{{ foreach $book in $books}}
<tr>
<td>{{ $book->title }}</td> <td>{{$book->author->name}}</td>
</tr>
{{ endforeach }}
Title {{ $book->title }}
Author {{ $book->author->name }}
Summary {{ $book->summary }}
class Book {
public function authors() {
return $this->authors;
}
public function byLine(){
$authorNames = array();
foreach($this->authors as $author) $authorNames[] = $author->name;
return join(', ', $authorNames);
}
}
{{ foreach $book in $books}}
<tr>
<td>{{ $book->title }}</td> <td>{{$book->byLine()}}</td>
</tr>
{{ endforeach }}
Title {{ $book->title }}
Author {{ $book->byLine() }}
Summary {{ $book->summary }}