mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-28 02:30:20 +02:00
31 lines
574 B
PHP
31 lines
574 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Behavioral\Iterator;
|
|
|
|
class Book
|
|
{
|
|
private string $author;
|
|
private string $title;
|
|
|
|
public function __construct(string $title, string $author)
|
|
{
|
|
$this->author = $author;
|
|
$this->title = $title;
|
|
}
|
|
|
|
public function getAuthor(): string
|
|
{
|
|
return $this->author;
|
|
}
|
|
|
|
public function getTitle(): string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function getAuthorAndTitle(): string
|
|
{
|
|
return $this->getTitle().' by '.$this->getAuthor();
|
|
}
|
|
}
|