removed Interface-suffix

This commit is contained in:
Dominik Liebler
2019-08-21 08:12:28 +02:00
parent e02bcea33f
commit 2627aab1d1
9 changed files with 50 additions and 50 deletions

View File

@@ -2,25 +2,11 @@
namespace DesignPatterns\Structural\Adapter;
class Book implements BookInterface
interface Book
{
/**
* @var int
*/
private $page;
public function turnPage();
public function open()
{
$this->page = 1;
}
public function open();
public function turnPage()
{
$this->page++;
}
public function getPage(): int
{
return $this->page;
}
public function getPage(): int;
}

View File

@@ -1,12 +0,0 @@
<?php declare(strict_types=1);
namespace DesignPatterns\Structural\Adapter;
interface BookInterface
{
public function turnPage();
public function open();
public function getPage(): int;
}

View File

@@ -2,7 +2,7 @@
namespace DesignPatterns\Structural\Adapter;
interface EBookInterface
interface EBook
{
public function unlock();

View File

@@ -3,20 +3,20 @@
namespace DesignPatterns\Structural\Adapter;
/**
* This is the adapter here. Notice it implements BookInterface,
* This is the adapter here. Notice it implements Book,
* therefore you don't have to change the code of the client which is using a Book
*/
class EBookAdapter implements BookInterface
class EBookAdapter implements Book
{
/**
* @var EBookInterface
* @var EBook
*/
protected $eBook;
/**
* @param EBookInterface $eBook
* @param EBook $eBook
*/
public function __construct(EBookInterface $eBook)
public function __construct(EBook $eBook)
{
$this->eBook = $eBook;
}
@@ -35,7 +35,7 @@ class EBookAdapter implements BookInterface
}
/**
* notice the adapted behavior here: EBookInterface::getPage() will return two integers, but BookInterface
* notice the adapted behavior here: EBook::getPage() will return two integers, but Book
* supports only a current page getter, so we adapt the behavior here
*
* @return int

View File

@@ -6,7 +6,7 @@ namespace DesignPatterns\Structural\Adapter;
* 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
class Kindle implements EBook
{
/**
* @var int

View File

@@ -0,0 +1,26 @@
<?php declare(strict_types=1);
namespace DesignPatterns\Structural\Adapter;
class PaperBook implements Book
{
/**
* @var int
*/
private $page;
public function open()
{
$this->page = 1;
}
public function turnPage()
{
$this->page++;
}
public function getPage(): int
{
return $this->page;
}
}

View File

@@ -28,27 +28,27 @@ Code
You can also find this code on `GitHub`_
BookInterface.php
.. literalinclude:: BookInterface.php
:language: php
:linenos:
Book.php
.. literalinclude:: Book.php
:language: php
:linenos:
EBookAdapter.php
PaperBook.php
.. literalinclude:: EBookAdapter.php
.. literalinclude:: PaperBook.php
:language: php
:linenos:
EBookInterface.php
EBook.php
.. literalinclude:: EBookInterface.php
.. literalinclude:: EBook.php
:language: php
:linenos:
EBookAdapter.php
.. literalinclude:: EBookAdapter.php
:language: php
:linenos:

View File

@@ -2,7 +2,7 @@
namespace DesignPatterns\Structural\Adapter\Tests;
use DesignPatterns\Structural\Adapter\Book;
use DesignPatterns\Structural\Adapter\PaperBook;
use DesignPatterns\Structural\Adapter\EBookAdapter;
use DesignPatterns\Structural\Adapter\Kindle;
use PHPUnit\Framework\TestCase;
@@ -11,7 +11,7 @@ class AdapterTest extends TestCase
{
public function testCanTurnPageOnBook()
{
$book = new Book();
$book = new PaperBook();
$book->open();
$book->turnPage();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 60 KiB