Design Patterns PHP - Facade Java

1) At the beginning

Let's imagine that we have three following classes.


class ClassA
{
    /**
     * @var string $a ;
     */
    protected $a;

    function __construct($a)
    {
        $this->a = $a;
    }

    public function doA()
    {
        $this->a .= ' doing A ';
    }

    /**
     * @return string
     */
    public function getA()
    {
        return $this->a;
    }
}

class ClassB
{
    /**
     * @var string $b ;
     */
    protected $b;

    public function doB()
    {
        $this->b .= 'doing B ';
    }

    /**
     * @param string $b
     */
    public function setB($b)
    {
        $this->b = $b;
    }

    /**
     * @return string
     */
    public function getB()
    {
        return $this->b;
    }
}

class ClassC
{
    /**
     * @var string
     */
    private $c;

    public function doC(ClassB $b)
    {
        $this->c = $b->getB() . 'doing C with B ';
    }

    /**
     * @return string
     */
    public function getC()
    {
        return $this->c;
    }
}




Yes this logic and relations between objects are really messy

2) And imagine Client


$a = new ClassA('something');
$b = new ClassB();
$c = new ClassC();

$a->doA();
$b->setB($a->getA());
$b->doB();
$c->doC($b);
$neededObj = $c->getC();




3) What is wrong with client?

As we see, client has to use quite messy and complicated interface of subsystems(ClassA, ClassB, ClassC) in order to receive desirable object.