I have an error class which I have made a Facade and a ServiceProvider for.
I use it like this:
Err::getLastError();
I have also another class for file validation:
FileValidate::IsImage($this->getUpload());
I want to inject the Err facade into the FileValidate
so that I use it like this:
FileValidate::Error()->getLastError();
How should I do this?
Now My approach is that, in FileValidate
class I add a member:
function Error()
{
return $this;
}
Though the above just returns the FileValidate
object, thus I add another method:
function getLastError()
{
return Err::getLastError();
}
But then for each method of Err
, I should make an alternative in FileValidate
and all Err like the above example. I need a more dynamic solution.