Factory Pattern
The Factory pattern creates objects without exposing the creation logic.
Example
Section titled “Example”class Car { public function drive() { echo "Driving car"; }}
class CarFactory { public static function create(): Car { return new Car(); }}
$car = CarFactory::create();$car->drive();