Skip to content

Instantly share code, notes, and snippets.

@rpayanm
Created July 12, 2019 20:21
Show Gist options
  • Save rpayanm/73358b3c0a9fa2037d1c37c3da2289e7 to your computer and use it in GitHub Desktop.
Save rpayanm/73358b3c0a9fa2037d1c37c3da2289e7 to your computer and use it in GitHub Desktop.

Object Composition (Sobrescribir una clase sin editarla)

In modern PHP, you're going to spend a lot of time working with other people's classes: via external libraries that you bring into your project to get things done faster. Of course, when you do that: you can't actually edit their code if you need to change or add some behavior.

Fortunately, OO code gives us some really neat ways to deal with this limitation. In this tutorial, you'll learn a method called composition in which we'll create a wrapper class, which has some subtle advantages over using inheritance.

https://symfonycasts.com/screencast/oo-ep4/composition-ftw

https://drive.google.com/file/d/1fTRmwiBB0cZzNQNYabM0SXUDErFIUaBk/view?usp=sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment