The open/closed principle states that a class should be open for extension but closed for modification, as per the definition found on Wikipedia:
"software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification"
The open for extension part means that we should design our classes so that new functionality can be added if needed. The closed for modification part means that this new functionality should fit in without modifying the original class. The class should only be modified in case of a bug fix, not for adding new functionality.
The following is an example of a class that violates the open/closed principle:
class CsvExporter { public function export($data) { // Implementation... } } class XmlExporter { public function export($data) { // Implementation... } } class GenericExporter { public function exportToFormat($data, $format) { if ('csv' === $format) { $exporter...