mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
cs Adapter
This commit is contained in:
parent
3b7eb295c8
commit
33671aec55
@ -1,9 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DesignPatternPHP
|
||||
*/
|
||||
|
||||
namespace DesignPatterns\Adapter;
|
||||
|
||||
/**
|
||||
@ -11,15 +7,19 @@ namespace DesignPatterns\Adapter;
|
||||
*/
|
||||
class Book implements PaperBookInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function open()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function turnPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ namespace DesignPatterns\Adapter;
|
||||
*/
|
||||
interface EBookInterface
|
||||
{
|
||||
|
||||
function pressNext();
|
||||
|
||||
function pressStart();
|
||||
|
@ -1,27 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DesignPatternPHP
|
||||
*/
|
||||
|
||||
namespace DesignPatterns\Adapter;
|
||||
|
||||
/**
|
||||
* Kindle is a concrete electronic book
|
||||
*
|
||||
* @author flo
|
||||
*/
|
||||
class Kindle implements ElecBookInterface
|
||||
class Kindle implements EBookInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pressNext()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pressStart()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DesignPatternPHP
|
||||
*/
|
||||
|
||||
namespace DesignPatterns\Adapter;
|
||||
|
||||
/**
|
||||
@ -11,8 +7,17 @@ namespace DesignPatterns\Adapter;
|
||||
*/
|
||||
interface PaperBookInterface
|
||||
{
|
||||
/**
|
||||
* method to turn pages
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function turnPage();
|
||||
|
||||
function turnPage();
|
||||
|
||||
function open();
|
||||
}
|
||||
/**
|
||||
* method to open the book
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function open();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace DesignPatterns\Tests\Adapter;
|
||||
|
||||
use DesignPatterns\Adapter\ElecBookAdapter;
|
||||
use DesignPatterns\Adapter\EBookAdapter;
|
||||
use DesignPatterns\Adapter\Kindle;
|
||||
use DesignPatterns\Adapter\PaperBookInterface;
|
||||
use DesignPatterns\Adapter\Book;
|
||||
@ -23,13 +23,13 @@ class AdapterTest extends \PHPUnit_Framework_TestCase
|
||||
return array(
|
||||
array(new Book()),
|
||||
// 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
|
||||
* is in fact an electronic book.
|
||||
* is in fact an electronic book, but both work the same way
|
||||
*
|
||||
* @dataProvider getBook
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user