i use PHP Mess Detector on my Laravel controller invokable class and i got message like this
Avoid using static access to class 'Illuminate\Support\Facades\Cache' in method '__invoke'
Can anyone explain it why i must avoid using static access on invoke method?
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Reference: https://phpmd.org/rules/cleancode.html#staticaccess