mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 17:52:25 +01:00
38 lines
606 B
PHP
38 lines
606 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\Iterator;
|
|
|
|
class Book
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $author;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $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();
|
|
}
|
|
}
|