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.
Description:
Scope a dependency injector, which will help reduce the instances of
Request::class
instantiated multiple times in theMacronutrientsController::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 theDependencyInjector::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
.