PHP the difference between 2 type of dependency injection [closed]
Solution 1:
Difference is the structure of your class. If you want to use more then in one function the injecting object you must use first for pretty code. If you want to use only in one function you must use second, because you must to think about load and what will do that class.
Updated
The "load" mean:
Then you make injection into the constructor, it will put all data into ram and waiting for use it (for faster processing), so let's thing if that your injection is very big object (large bits amount placed into ram and slow load it), so your script will make respond longer, for everything what you code process. Then you will use more then in one class that for ex. large object, then you can inject it to constructor, anyway you will not pointless code if it will be use right.
Summary:
There is not very difference, if it only once using or small parts. But if you make have all your's code heavy, so your load will be same slowly.
Make your code light and easy to use your self and computer.