Slide 15
Slide 15 text
Copyright© M&A
15
Predefined Interfaces
Predefined Interface
class BookShelf implements Iterator {
… ུ …
public function addNewArrival(string $name, int $price)
{
$this->books[] = new Book($name, $price, isNew: true);
}
}
$books = [
new Book(name: 'PHPϑϨʔϜϫʔΫ Laravel WebΞϓϦέʔγϣϯ։ൃ όʔδϣϯ5.5 LTSରԠ', price: 4180),
new Book(name: 'ΈΜͳͷPHPɹݱͰཱͭ࠷৽ϊϋʂ', price: 2398)
];
$boolShelf = new BookShelf($books);
$boolShelf->addNewArrival(name: 'ϓϩϑΣογϣφϧWebϓϩάϥϛϯά Laravelʪ࠷৽Laravel 9ରԠʫ', price: 3520);
foreach ($boolShelf as $book) {
print($book);
print("\n");
}