I am currently writing a few classes to deal with localization in a PHP web application.
The classes are:
The whole application works properly, but I need to add a few more things to Timezone.
This results in this problem: Locale requires Timezone's methods which requires LocaleData's methods which requires Locale's methods.
How can I break this circular dependency? Should I break my classes down into smaller pieces? Are there any patterns for dealing with this?
Cheers :)
If you are only calling methods from other classes, load all the classes first, then you can call the methods between the classes. Don't perform any initialization within the class files, that should be done in a separate "loader" file that "includes" the files, then calls the does initialization.
If you are getting circular dependencies based on classes extending other classes, then you need to rethink the whole setup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With