php - Object creation variable construct values -


i trying figure out if there solution following problem:

lets have class named openfiles. constructor requires path file open , object required openfiles.

class openfiles {     public function __construct(object $object,$filepath)     {         //code           } } 

the $object same can found in sort of container. filepath different each time class needed.

my 'problem' when class changes need go on code , edit accordingly.

is there pattern or solution this? or inevitable?

thanks in advance!

i suggest using interface object , use interface input param function.

interface ipermissioncollection {     public function getpermission($name); } 

then change class use interface instead of object.

class openfiles {     public function __construct(ipermissioncollection $object,$filepath)     {         //code           } } 

and if want send different class later sure implement ipermissioncollection.

so question not how handle code refactoring if chage class constructor use multiple time question how write such class uses needs , scale.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -