Say I have class Foo with static public method bar(), and I want to make restriction in order to use this method in "right" places.
The solution I came so far is:
interface FooContext {}
class Foo
{
static public function bar(FooContext $context)
{
// some logic
}
}
class Execution implements FooContext
{
Foo::bar($this);
}
so I can be sure that Foo::bar will be used only in safe places.
Is there any better solutions resolving this problem?
(Assuming that I'm not using Dependency Injection)
Aucun commentaire:
Enregistrer un commentaire