How can the Facade pattern be used to improve code organization in PHP?

When working on a complex system, code organization can become messy and hard to maintain. The Facade pattern can help improve code organization by providing a simplified interface to a set of interfaces in a subsystem. This allows clients to interact with the system through a single interface, reducing dependencies and making the codebase more cohesive.

<?php
// Subsystem classes
class SubsystemA {
    public function operationA() {
        echo "Subsystem A operation\n";
    }
}

class SubsystemB {
    public function operationB() {
        echo "Subsystem B operation\n";
    }
}

// Facade class
class Facade {
    private $subsystemA;
    private $subsystemB;

    public function __construct() {
        $this->subsystemA = new SubsystemA();
        $this->subsystemB = new SubsystemB();
    }

    public function operation() {
        $this->subsystemA->operationA();
        $this->subsystemB->operationB();
    }
}

// Client code
$facade = new Facade();
$facade->operation();
?>