Bog'liq The-Clean-Architecture-in-PHP-Kristopher-Wilson
Adapter Pattern The Adapter Pattern allows for encapsulating the functionality of one object, and making it
conform to the functionality of another object. This pattern is sometimes also referred to as the
Wrapper Pattern, as it involves wrapping one object with another.
Let’s say we have one class whose interface looks something like this:
⁶
http://www.doctrine-project.org/projects/orm.html
⁷
http://laravel.com/docs/eloquent
⁸
http://propelorm.org/
⁹
http://framework.zend.com/
¹⁰
http://martinfowler.com/books/eaa.html
Design Patterns, A Primer
27
class GoogleMapsApi {
public function getWalkingDirections
(
$from
,
$to
) {}
}
We have an interface in our project that defines the structure of an object that gets us distances: