I want to use a trait in a class, only if a condition is satisfied. For example:
trait T
{
}
class A
{
if ($condition) {
use T;
}
}
I know I can't use if
directly in class. So, I'm looking for a way to use traits conditionally similar to the above. Is it possible?