I am currently writing a few classes to deal with localization in a PHP web application.
The classes are:
- Locale - Deals with setting and getting the user's locale, timezone, language.
- LocaleFormat - Deals with formatting dates, collations, currency formats, etc.
- Timezone - Deals with compiling a list of time zones for countries and other functions related to timezones.
- LocaleData - Fetches locale data, for example address formats and things like post code regexes.
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 :)