38 lines
606 B
PHP
Raw Normal View History

2014-03-24 10:40:08 -03:00
<?php
namespace DesignPatterns\Behavioral\Iterator;
class Book
{
2016-09-21 14:34:24 +02:00
/**
* @var string
*/
2014-03-24 10:40:08 -03:00
private $author;
2016-09-21 14:34:24 +02:00
/**
* @var string
*/
2014-03-24 10:40:08 -03:00
private $title;
2016-09-21 14:34:24 +02:00
public function __construct(string $title, string $author)
2014-03-24 10:40:08 -03:00
{
$this->author = $author;
$this->title = $title;
}
2016-09-21 14:34:24 +02:00
public function getAuthor(): string
2014-03-24 10:40:08 -03:00
{
return $this->author;
}
2016-09-21 14:34:24 +02:00
public function getTitle(): string
2014-03-24 10:40:08 -03:00
{
return $this->title;
}
2016-09-21 14:34:24 +02:00
public function getAuthorAndTitle(): string
2014-03-24 10:40:08 -03:00
{
2015-12-21 07:28:20 -05:00
return $this->getTitle().' by '.$this->getAuthor();
2014-03-24 10:40:08 -03:00
}
}