LabiciIvan / php-api-nutritional-project

A PHP API nutritional project
0 stars 0 forks source link

Dependencies Injector #22

Closed LabiciIvan closed 2 months ago

LabiciIvan commented 2 months ago

Description:

Scope a dependency injector, which will help reduce the instances of Request::class instantiated multiple times in the MacronutrientsController::class by creating instances once and injecting them as parameters to that class.

Create a class named DependencyInjector::class which will implement two methods.

Method hasDepedencies() - will find if a method from a class requires any dependencies to be injected, and will return an array of dependencies or null if there are no dependecies.

Class Application::class will be refactored to use the DependencyInjector::class and inject if there any method needs to be injected and if not then call the method without injecting anything in it.

Requires to write some unit tests which will showcase the use and functionality of the DependencyInjector::class.