35 lines
746 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
2013-05-11 20:54:21 +02:00
namespace DesignPatterns\Structural\Adapter;
2013-05-11 20:54:21 +02:00
/**
2016-09-22 20:09:07 +02:00
* this is the adapted class. In production code, this could be a class from another package, some vendor code.
* Notice that it uses another naming scheme and the implementation does something similar but in another way
2013-05-11 20:54:21 +02:00
*/
2019-08-21 08:12:28 +02:00
class Kindle implements EBook
2013-05-11 20:54:21 +02:00
{
2019-12-14 12:50:05 +01:00
private int $page = 1;
private int $totalPages = 100;
2016-09-22 20:09:07 +02:00
2013-05-11 20:54:21 +02:00
public function pressNext()
2016-09-22 20:09:07 +02:00
{
$this->page++;
}
public function unlock()
2013-05-11 20:54:21 +02:00
{
}
2013-09-09 10:50:00 +02:00
/**
2016-09-22 20:09:07 +02:00
* returns current page and total number of pages, like [10, 100] is page 10 of 100
*
* @return int[]
2013-09-09 10:50:00 +02:00
*/
2016-09-22 20:09:07 +02:00
public function getPage(): array
2013-05-11 20:54:21 +02:00
{
2016-09-22 20:09:07 +02:00
return [$this->page, $this->totalPages];
2013-09-09 10:50:00 +02:00
}
}