Only generic methods in Trait?

Hi there.

Basic question about Trait .
Should a Trait only contain “generic” methods ?

By generic i mean, Trait can be used in any class ?
Or a Trait can be specific to a class or a class who use another Trait ?
Example : a Trait for Entity, who use EntityTrait, and my Trait “require” methods in EntityTrait.

Is it ok for a Trait to be dependent ?


The way I see it, traits are what you use when you want to add common bits of functionality across classes, where inheritance doesn’t make sense. If you have a scenario where it doesn’t make sense to extend EntityTrait, then I’d say a trait is just fine.

1 Like

Thanks for your reply.