m4tlch / solid-php

SOLID principles with examples in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solid PHP - solid principles in PHP

PHP code examples for the SOLID rules, referring to the blog post: Solid PHP - SOLID principles in PHP


Single responsibility principle (SRP)

There should never be more than one reason for a class to change.

SRP - explanation

Examples:


Open/closed principle (OCP)

Software entities ... should be open for extension, but closed for modification.

OCP - explanation

Examples:


Liskov substitution principle (LSP)

Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.

LSP - explanation

Examples:


Interface segregation principle (ISP)

Many client-specific interfaces are better than one general-purpose interface.

ISP - explanation

Examples:


Dependency inversion principle (DIP)

Depend upon abstractions, NOT concretions.

DIP - explanation

Examples:

About

SOLID principles with examples in PHP


Languages

Language:PHP 100.0%