inheritance - Extending functionality to object PHP -


i creating class in php want extend class can have many basic functionality. problem functionality different , not want mix different methods in 1 class. due organization , extensibility prefer separate them logically.

let's imagine have 3 classes:

class user{ }

class tracker { }

class lister { }

user main class representing real-life object. without minding on concrete functionality of classes, both tracker , lister provide methods must appliable in user because kind of helpers. if use inheritance able inherit once time having create many classes "extends" add , finishing hierarchy class user. there option avoid doing this? mean possible extend user class functionality of other classes without having in way have said knowing php not support multiple inheritance?

thank you!

it classes or decorate user class, may better use implementation of decorator pattern.

$user = new user(); //default behavior $user->getmethod();  $tracker = new tracker($user); //enhanced behavior $tracker->getmethod(); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -