I am currently writing several classes for working with localization in a PHP web application.
Classes:
- Locale - works with settings and gets user language, time zone, language.
- LocaleFormat - works with formatting dates, comparisons, currency formats, etc.
- Time Zone - Deal with a list of time zones for countries and other time zone related functions.
- LocaleData - Retrieves locale data, such as address formats and things like regular expressions of a postal code.
The whole application works correctly, but I need to add a few more things to Timezone.
This leads to this problem: Locale requires Timezone methods, which require LocaleData methods, which require Locale methods.
How can I break this cyclic dependency? Should I break my classes into smaller pieces? Are there any patterns to solve this problem?
Greetings :)
source share