cs Adapter

This commit is contained in:
Dominik Liebler
2013-09-09 10:50:00 +02:00
parent 3b7eb295c8
commit 33671aec55
5 changed files with 35 additions and 33 deletions

View File

@@ -1,9 +1,5 @@
<?php <?php
/*
* DesignPatternPHP
*/
namespace DesignPatterns\Adapter; namespace DesignPatterns\Adapter;
/** /**
@@ -11,15 +7,19 @@ namespace DesignPatterns\Adapter;
*/ */
class Book implements PaperBookInterface class Book implements PaperBookInterface
{ {
/**
* {@inheritdoc}
*/
public function open() public function open()
{ {
} }
/**
* {@inheritdoc}
*/
public function turnPage() public function turnPage()
{ {
}
} }
}

View File

@@ -7,7 +7,6 @@ namespace DesignPatterns\Adapter;
*/ */
interface EBookInterface interface EBookInterface
{ {
function pressNext(); function pressNext();
function pressStart(); function pressStart();

View File

@@ -1,27 +1,25 @@
<?php <?php
/*
* DesignPatternPHP
*/
namespace DesignPatterns\Adapter; namespace DesignPatterns\Adapter;
/** /**
* Kindle is a concrete electronic book * Kindle is a concrete electronic book
*
* @author flo
*/ */
class Kindle implements ElecBookInterface class Kindle implements EBookInterface
{ {
/**
* {@inheritdoc}
*/
public function pressNext() public function pressNext()
{ {
} }
/**
* {@inheritdoc}
*/
public function pressStart() public function pressStart()
{ {
}
} }
}

View File

@@ -1,9 +1,5 @@
<?php <?php
/*
* DesignPatternPHP
*/
namespace DesignPatterns\Adapter; namespace DesignPatterns\Adapter;
/** /**
@@ -11,8 +7,17 @@ namespace DesignPatterns\Adapter;
*/ */
interface PaperBookInterface interface PaperBookInterface
{ {
/**
* method to turn pages
*
* @return mixed
*/
public function turnPage();
function turnPage(); /**
* method to open the book
function open(); *
} * @return mixed
*/
public function open();
}

View File

@@ -6,7 +6,7 @@
namespace DesignPatterns\Tests\Adapter; namespace DesignPatterns\Tests\Adapter;
use DesignPatterns\Adapter\ElecBookAdapter; use DesignPatterns\Adapter\EBookAdapter;
use DesignPatterns\Adapter\Kindle; use DesignPatterns\Adapter\Kindle;
use DesignPatterns\Adapter\PaperBookInterface; use DesignPatterns\Adapter\PaperBookInterface;
use DesignPatterns\Adapter\Book; use DesignPatterns\Adapter\Book;
@@ -23,13 +23,13 @@ class AdapterTest extends \PHPUnit_Framework_TestCase
return array( return array(
array(new Book()), array(new Book()),
// we build a "wrapped" electronic book in the adapter // we build a "wrapped" electronic book in the adapter
array(new ElecBookAdapter(new Kindle())) array(new EBookAdapter(new Kindle()))
); );
} }
/** /**
* This client only knows paper book but surprise, surprise, the second book * This client only knows paper book but surprise, surprise, the second book
* is in fact an electronic book. * is in fact an electronic book, but both work the same way
* *
* @dataProvider getBook * @dataProvider getBook
*/ */