Behavior Best Practice

Just randomly I recently developed two behaviours, both took slightly different routes due to the way they evolved. The first added a method to get another object that when could be used to modify data related to the owner. The second added a series of methods to the owner that also modified data related to the owner. Now, my thinking is that having the behaviour return an object that you then utilise reduces the amount of methods you’re adding to the owner and prevents potential clashing between behaviours. Whereas the other keeps things a little more simple and the behaviour is encapsulated within the model.

I’m looking for thoughts on best practice here.

Well, you can always call behavior methods explicitly to avoid clashing:

$model->taggable->setTags(array('PHP', 'Yii'));