rpodwika/designpatterns

PHP Design Patterns

1.10.0 2016-06-15 19:20 UTC

This package is auto-updated.

Last update: 2024-04-23 08:37:49 UTC


README

#Design Patterns for PHP

Build Status Coverage Status Dependency Status Latest Stable Version Total Downloads Latest Unstable Version License

##Why

For my own pratice and to help other programmers I decided to implement several Design Patterns in PHP. I hope you like it and you will find it helpful. If you have any suggestions how can I write something better please create pull request or message me

##What are design patterns

Design problems are proven to work solutions for problems that often occur while writing applications.

##Why to use them

Because they solve problems. You do not need to invent solution that is already working. How many times during your programmer career you had this feeling that you already solved problem that you are facing now? Same goes with patterns you have problem that could be solved using specific pattern. Keep in mind that you should not force your code to fit in patterns. It should come out naturally. Firstly K.I.S.S.

##Implemented patterns

  1. Antipatterns
  2. Behavioral
    • Adapter - adapt class behavior to new conditions without modifying source of original class
    • Chain of responsibility - Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request
    • Memento - Without violating encapsulation, capture and externalize an object's internal state
    • Observer - Define one to many dependency between objects so that when one changes state, all its dependents are notified and updated automatically
    • Proxy - Do some operations before giving access to origin object
    • State - allow object to alter its behavior depending on current internal state change.
    • Strategy - Define a family of algorithms and make them interchangeable.
  3. Creational
    • Abstract Factory - Provides interface for creating families of objects working together without specification of concrete classes
    • Factory - Define an interface for creating an object but let the subclasses decide which class to instantiate
  4. Structural
    • Decorator - Attach additional object features dynamically without subclassing or modifying source class.

##To be implemented

  • Builder
  • Prototype
  • Bridge
  • Composite
  • Facade
  • Flyweight
  • Command
  • Interpreter
  • Iterator
  • Mediator
  • Visitor