Design Patterns PHP - Adapter Java

1) What has changed?

We just added "Adapter" class which implements LibraryOne and inheriting from LibraryTwoImpl.
As "Adapter" implements "LibraryOne" we easily replace object of "LibraryOneImpl" with object of "Adapter" class.


class Adapter extends LibraryTwoImpl implements LibraryOne
{
    public function doAB()
    {
        $this->doA();
        $this->doB();
    }
}




2) What we achieved?

Don't changing client code and libraries at all in nice way we replace using "LibraryOne" with "LibraryTwo"


/** @var LibraryOne $library */
$library->doAB();




3) Is it exist another solution?

Yes, in this solution we use inheritance of implementation in Adapter. This "Adapter" is called "class adapter".
Please let's see step3 and show alternative solution called "object adapter".