Design Patterns PHP - Bridge Java

1) What have we done?

We created a class "ChildA"

We changed implementation of particular steps.


class ClassA
{
    public function doA()
    {
        $this->doStep1();
        $this->doStep2();
        $this->doStep3();
    }

    protected function doStep1()
    {
        echo 'ClassA doing step 1' . PHP_EOL;
    }

    protected function doStep2()
    {
        echo 'ClassA doing step 2' . PHP_EOL;
    }

    protected function doStep3()
    {
        echo 'ClassA doing step 3' . PHP_EOL;
    }
}

class ChildA extends ClassA
{
    protected function doStep1()
    {
        echo 'ChildA doing step 1' . PHP_EOL;
    }

    protected function doStep2()
    {
        echo 'ChildA doing step 2' . PHP_EOL;
    }

    protected function doStep3()
    {
        echo 'ChildA doing step 3' . PHP_EOL;
    }
}




2) Is everything ok?

It seems that everything is ok but turned out that we have to add a new method into "ClassA".

Moreover let's suppose that we can't change "ClassA" (for example it is class from some library).

So we need to create another child class. Let's see how this look in step3.