1<?php
2class Automobile
3{
4 private $vehicleMake;
5 private $vehicleModel;
6
7 public function __construct($make, $model)
8 {
9 $this->vehicleMake = $make;
10 $this->vehicleModel = $model;
11 }
12
13 public function getMakeAndModel()
14 {
15 return $this->vehicleMake . ' ' . $this->vehicleModel;
16 }
17}
18
19class AutomobileFactory
20{
21 public static function create($make, $model)
22 {
23 return new Automobile($make, $model);
24 }
25}
26
27// have the factory create the Automobile object
28$veyron = AutomobileFactory::create('Bugatti', 'Veyron');
29
30print_r($veyron->getMakeAndModel()); // outputs "Bugatti Veyron"