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 abstract factory pattern

Abstract factory encapsulates a group of individual factories that have a common functionality. It does so without specifying their concrete classes. This makes it easier to write portable code, because clients can interchange concrete implementations without changing the code.

The following example demonstrates a possible abstract factory pattern implementation:

<?phpinterface Button{    public function render();}interface FormFactory{    public function createButton();}class LoginButton implements Button{    public function render()    {        return '<button name="login">Login</button>';    }}class RegisterButton implements Button{    public function render()    {        return '<button name="register">Register</button>';    }}class LoginFactory ...
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