Skip to Content
Mastering PHP 7
book

Mastering PHP 7

by Branko Ajzele
June 2017
Intermediate to advanced
536 pages
9h 49m
English
Packt Publishing
Content preview from Mastering PHP 7

The builder pattern

The builder pattern is quite a handy one, especially when it comes to large applications. It separates the construction of a complex object from its representation. This makes it possible for the same construction process to create numerous representations.

The following example demonstrates a possible builder pattern implementation using the Image class as an example:

<?phpclass Image{    private $width;    private $height;    public function getWidth()    {        return $this->width;    }    public function setWidth($width)    {        $this->width = $width;        return $this;    }    public function getHeight()    {        return $this->height;    }    public function setHeight($height)    {        $this->height = $height;        return $this;    }}interface ImageBuilderInterface{    public function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning PHP 7

Learning PHP 7

Antonio L Zapata (GBP)
Upgrading to PHP 5

Upgrading to PHP 5

Adam Trachtenberg

Publisher Resources

ISBN: 9781785882814Supplemental Content