Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Tests Replaced with strict assertions Sep 29, 2018
uml generated Adapter UML Jan 10, 2017
Book.php PHP7 Adapter Sep 22, 2016
BookInterface.php PHP7 Adapter Sep 22, 2016
EBookAdapter.php PHP7 Adapter Sep 22, 2016
EBookInterface.php PHP7 Adapter Sep 22, 2016
Kindle.php PHP7 Adapter Sep 22, 2016
README.rst Improve grammar: these code > this code Apr 4, 2017

README.rst

Adapter / Wrapper

Purpose

To translate one interface for a class into a compatible interface. An adapter allows classes to work together that normally could not because of incompatible interfaces by providing its interface to clients while using the original interface.

Examples

  • DB Client libraries adapter
  • using multiple different webservices and adapters normalize data so that the outcome is the same for all

UML Diagram

Alt Adapter UML Diagram

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

.. literalinclude:: EBookAdapter.php
   :language: php
   :linenos:

EBookInterface.php

.. literalinclude:: EBookInterface.php
   :language: php
   :linenos:

Kindle.php

.. literalinclude:: Kindle.php
   :language: php
   :linenos:

Test

Tests/AdapterTest.php

.. literalinclude:: Tests/AdapterTest.php
   :language: php
   :linenos: