Builder is an interface that build parts of a complex object.
Sometimes, if the builder has a better knowledge of what it builds, this interface could be an abstract class with default methods (aka adapter).
If you have a complex inheritance tree for objects, it is logical to have a complex inheritance tree for builders too.
Note: Builders have often a fluent interface, see the mock builder of PHPUnit for example.
- PHPUnit: Mock Builder
You can also find these code on GitHub
Director.php
Director.php
BuilderInterface.php
BuilderInterface.php
BikeBuilder.php
BikeBuilder.php
CarBuilder.php
CarBuilder.php
Parts/Vehicle.php
Parts/Vehicle.php
Parts/Bike.php
Parts/Bike.php
Parts/Car.php
Parts/Car.php
Parts/Engine.php
Parts/Engine.php
Parts/Wheel.php
Parts/Wheel.php
Parts/Door.php
Parts/Door.php
Tests/DirectorTest.php
Tests/DirectorTest.php