mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 20:20:15 +02:00
PHP7 Adapter
This commit is contained in:
@@ -3,21 +3,37 @@
|
||||
namespace DesignPatterns\Structural\Adapter;
|
||||
|
||||
/**
|
||||
* Kindle is a concrete electronic book.
|
||||
* 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
|
||||
*/
|
||||
class Kindle implements EBookInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @var int
|
||||
*/
|
||||
private $page = 1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $totalPages = 100;
|
||||
|
||||
public function pressNext()
|
||||
{
|
||||
$this->page++;
|
||||
}
|
||||
|
||||
public function unlock()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* returns current page and total number of pages, like [10, 100] is page 10 of 100
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function pressStart()
|
||||
public function getPage(): array
|
||||
{
|
||||
return [$this->page, $this->totalPages];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user