This repository contains materials and exercises for a course on Object-Oriented Programming (OOP) in PHP. The course covers several key concepts in OOP, including constructors, inheritance, and visibility.
Based in 4 pillars of OOP: Encapsulation, Abstraction, Inheritance and Polymorphism.
In PHP, a constructor is a special "magic" method that is automatically called when an object is created. It's typically used to initialize the properties of the object. In this course, you'll learn how to define and use constructors in your PHP classes.
Inheritance is a fundamental concept in OOP that allows you to define a new class based on an existing class. This allows you to reuse code and create more specialized classes based on general ones. This course will teach you how to use inheritance in PHP to create more efficient and organized code.
Visibility in PHP OOP refers to the accessibility of properties and methods in a class. There are three levels of visibility:
In this course, you'll learn how to use these different levels of visibility to control access to your code.
- `::` Scope Resolution Operator
- Like the `__toString` method is called when an object is used in a string context.
- Getters and Setters can have property names passed to get around multiple method calls
- An abstract class is a class that **cannot be instantiated on its own** and is typically used as a base class for other classes.
- The abstract class provides properties and funciontality which is shared by all the classes that inherit from it.
- Declared in an abstract class implementation is provided by the classes that inherit from the abstract class.
- if class extends three dimensions shape aka abstract it must implement the abstract method `getVolume`
- Good for:
- You want to provide a common interface for different classes
- You want to enforce certain methods to be implemented by the child class
- You are designing a large functional unit by using the Template Method patter
- Default implementation of a method in an interface
- Objects that can take on many forms
- an instance of an object that can take more than one type is polymorphic
- Injecting this single type is not as usefull `public function updateStockFromFile(string $path, CsvFileReader $fileReader): array`
- Using `instanceof` we can check if the object is of a certain type
- Closure functions
- Abstract classes and methods
- Uml diagrams
- Dependency injection
PHP
OOP
Learning-PHP
PHP-Course
Constructors
Inheritance
Visibility
Encapsulation
Abstraction
Polymorphism
PHPUnit
PDO
Namespaces
Autoloading
Traits
Error-Handling
MySQL
Composer
Testing-PHP
Test-Driven-Development