Are there any contradictions to use traits to inject helper methods like this?
class Foo { use Helper\Array; function isFooValid(array $foo) { return $this->arrayContainsOnly('BarClass', $foo); } }
Are there any contradictions to use traits to inject helper methods like this?
class Foo { use Helper\Array; function isFooValid(array $foo) { return $this->arrayContainsOnly('BarClass', $foo); } }
That's the idea with traits.
However you should still keep an eye out for coupled code. If Helper\Array
is a completely different namespace from what Foo
is in you might want to re-think this particular approach.